diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /parts/astyle | |
download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'parts/astyle')
-rw-r--r-- | parts/astyle/Makefile.am | 16 | ||||
-rw-r--r-- | parts/astyle/README.dox | 10 | ||||
-rw-r--r-- | parts/astyle/astyle_adaptor.cpp | 270 | ||||
-rw-r--r-- | parts/astyle/astyle_adaptor.h | 55 | ||||
-rw-r--r-- | parts/astyle/astyle_part.cpp | 541 | ||||
-rw-r--r-- | parts/astyle/astyle_part.h | 76 | ||||
-rw-r--r-- | parts/astyle/astyle_widget.cpp | 346 | ||||
-rw-r--r-- | parts/astyle/astyle_widget.h | 36 | ||||
-rw-r--r-- | parts/astyle/astyleconfig.ui | 1332 | ||||
-rw-r--r-- | parts/astyle/kdevastyle.desktop | 82 | ||||
-rw-r--r-- | parts/astyle/kdevpart_astyle.rc | 17 |
11 files changed, 2781 insertions, 0 deletions
diff --git a/parts/astyle/Makefile.am b/parts/astyle/Makefile.am new file mode 100644 index 00000000..dc3712b2 --- /dev/null +++ b/parts/astyle/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = -I$(top_srcdir)/lib/astyle -I$(top_srcdir)/lib/interfaces \ + -I$(top_srcdir)/lib/interfaces/extensions -I$(top_srcdir)/lib/util $(all_includes) + +kde_module_LTLIBRARIES = libkdevastyle.la +libkdevastyle_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkdevastyle_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \ + $(top_builddir)/lib/astyle/libastyle.la + +libkdevastyle_la_SOURCES = astyle_part.cpp astyleconfig.ui astyle_widget.cpp astyle_adaptor.cpp +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = kdevastyle.desktop + +rc_DATA = kdevpart_astyle.rc +rcdir = $(kde_datadir)/kdevastyle diff --git a/parts/astyle/README.dox b/parts/astyle/README.dox new file mode 100644 index 00000000..4b7d4778 --- /dev/null +++ b/parts/astyle/README.dox @@ -0,0 +1,10 @@ +/** \class AStylePart +A plugin for formatting of sourcecode according to a specified set of rules. + +\authors <a href="mailto: <mhk AT caldera.de>">Matthias Hlzer-Klpfel</a> + +\feature formats source code according to a specified set of rules + +\bug bugs in <a href="http://bugs.kde.org/buglist.cgi?product=kdevelop&component=astyle&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=Bug+Number">astyle component at Bugzilla database</a> + +*/ diff --git a/parts/astyle/astyle_adaptor.cpp b/parts/astyle/astyle_adaptor.cpp new file mode 100644 index 00000000..124da96e --- /dev/null +++ b/parts/astyle/astyle_adaptor.cpp @@ -0,0 +1,270 @@ +#include "astyle_adaptor.h" + +#include "astyle_widget.h" + +#include <string> + +#include <qradiobutton.h> +#include <qspinbox.h> +#include <qcheckbox.h> +#include <kdebug.h> +#include <kapplication.h> +#include <kconfig.h> + + + +ASStringIterator::ASStringIterator(const QString &text) + : ASSourceIterator(), _content(text) +{ + _is = new QTextStream(&_content, IO_ReadOnly); +} + + +ASStringIterator::~ASStringIterator() +{ + delete _is; +} + + +bool ASStringIterator::hasMoreLines() const +{ + return !_is->eof(); +} + + +string ASStringIterator::nextLine() +{ + return _is->readLine().utf8().data(); +} + + +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") + { + setTabIndentation(wsCount, options["FillForce"].toBool() ); + m_indentString = "\t"; + } else + { + setSpaceIndentation(wsCount); + m_indentString = ""; + m_indentString.fill(' ', wsCount); + } + + setTabSpaceConversionMode(options["FillForce"].toBool()); + setEmptyLineFill(options["Fill_EmptyLines"].toBool()); + + // indent + setSwitchIndent(options["IndentSwitches"].toBool()); + setClassIndent(options["IndentClasses"].toBool()); + setCaseIndent(options["IndentCases"].toBool()); + 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()); + if (options["MinConditional"].toInt() != -1) + setMinConditionalIndentLength(options["MinConditional"].toInt()); + + // brackets + s = options["Brackets"].toString(); + if (s == "Break") + setBracketFormatMode(astyle::BREAK_MODE); + else if (s == "Attach") + setBracketFormatMode(astyle::ATTACH_MODE); + else if (s == "Linux") + setBracketFormatMode(astyle::BDAC_MODE); + else + setBracketFormatMode(astyle::NONE_MODE); + + setBreakClosingHeaderBracketsMode(options["BracketsCloseHeaders"].toBool()); + // blocks + setBreakBlocksMode(options["BlockBreak"].toBool()); + if (options["BlockBreakAll"].toBool()){ + setBreakBlocksMode(true); + setBreakClosingHeaderBlocksMode(true); + } + 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 ) +{ + setCStyle(); + + if ( widget->Style_ANSI->isChecked() ) + { + predefinedStyle( "ANSI" ); + return; + } + if ( widget->Style_GNU->isChecked() ) + { + predefinedStyle( "GNU" ); + return; + } + if ( widget->Style_JAVA->isChecked() ) + { + predefinedStyle( "JAVA" ); + return; + } + if ( widget->Style_KR->isChecked() ) + { + predefinedStyle( "KR" ); + return; + } + if ( widget->Style_Linux->isChecked() ) + { + predefinedStyle( "Linux" ); + return; + } + + // fill + if ( widget->Fill_Tabs->isChecked() ) + { + setTabIndentation(widget->Fill_TabCount->value(), widget->Fill_ForceTabs->isChecked()); + m_indentString = "\t"; + } + else + { + setSpaceIndentation( widget->Fill_SpaceCount->value() ); + m_indentString = ""; + m_indentString.fill(' ', widget->Fill_SpaceCount->value()); + } + + setTabSpaceConversionMode(widget->Fill_ConvertTabs->isChecked()); + setEmptyLineFill(widget->Fill_EmptyLines->isChecked()); + + // indent + setSwitchIndent( widget->Indent_Switches->isChecked() ); + setClassIndent( widget->Indent_Classes->isChecked() ); + setCaseIndent( widget->Indent_Cases->isChecked() ); + setBracketIndent( widget->Indent_Brackets->isChecked() ); + setNamespaceIndent( widget->Indent_Namespaces->isChecked() ); + setLabelIndent( widget->Indent_Labels->isChecked() ); + setBlockIndent( widget->Indent_Blocks->isChecked()); + setPreprocessorIndent(widget->Indent_Preprocessors->isChecked()); + + // continuation + setMaxInStatementIndentLength( widget->Continue_MaxStatement->value() ); + setMinConditionalIndentLength( widget->Continue_MinConditional->value() ); + + // brackets + if ( widget->Brackets_Break->isChecked() ) + { + setBracketFormatMode( astyle::BREAK_MODE ); + } + else if ( widget->Brackets_Attach->isChecked() ) + { + setBracketFormatMode( astyle::ATTACH_MODE ); + } + else if ( widget->Brackets_Linux->isChecked()) + { + setBracketFormatMode( astyle::BDAC_MODE ); + } + else{ + setBracketFormatMode( astyle::NONE_MODE ); + } + + setBreakClosingHeaderBracketsMode( widget->Brackets_CloseHeaders->isChecked()); + + // blocks + setBreakBlocksMode(widget->Block_Break->isChecked()); + if (widget->Block_BreakAll->isChecked()){ + setBreakBlocksMode(true); + setBreakClosingHeaderBlocksMode(true); + } + setBreakElseIfsMode(widget->Block_IfElse->isChecked()); + + // padding + setOperatorPaddingMode( widget->Pad_Operators->isChecked() ); + + setParensInsidePaddingMode( widget->Pad_ParenthesesIn->isChecked() ); + setParensOutsidePaddingMode( widget->Pad_ParenthesesOut->isChecked() ); + setParensUnPaddingMode( widget->Pad_ParenthesesUn->isChecked() ); + + // oneliner + setBreakOneLineBlocksMode( !widget->Keep_Blocks->isChecked() ); + setSingleStatementsMode( !widget->Keep_Statements->isChecked() ); +} + +bool KDevFormatter::predefinedStyle( const QString & style ) +{ + if (style == "ANSI") + { + setBracketIndent(false); + setSpaceIndentation(4); + setBracketFormatMode(astyle::BREAK_MODE); + setClassIndent(false); + setSwitchIndent(false); + setNamespaceIndent(false); + return true; + } + if (style == "KR") + { + setBracketIndent(false); + setSpaceIndentation(4); + setBracketFormatMode(astyle::ATTACH_MODE); + setClassIndent(false); + setSwitchIndent(false); + setNamespaceIndent(false); + return true; + } + if (style == "Linux") + { + setBracketIndent(false); + setSpaceIndentation(8); + setBracketFormatMode(astyle::BDAC_MODE); + setClassIndent(false); + setSwitchIndent(false); + setNamespaceIndent(false); + return true; + } + if (style == "GNU") + { + setBlockIndent(true); + setSpaceIndentation(2); + setBracketFormatMode(astyle::BREAK_MODE); + setClassIndent(false); + setSwitchIndent(false); + setNamespaceIndent(false); + return true; + } + if (style == "JAVA") + { + setJavaStyle(); + setBracketIndent(false); + setSpaceIndentation(4); + setBracketFormatMode(astyle::ATTACH_MODE); + setSwitchIndent(false); + return true; + } + return false; +} diff --git a/parts/astyle/astyle_adaptor.h b/parts/astyle/astyle_adaptor.h new file mode 100644 index 00000000..2367c4d7 --- /dev/null +++ b/parts/astyle/astyle_adaptor.h @@ -0,0 +1,55 @@ +#ifndef __ASTYLE_ADAPTOR_H__ +#define __ASTYLE_ADAPTOR_H__ + + +#include <qstring.h> +#include <qtextstream.h> +#include <qmap.h> +#include <qvariant.h> + +#include "astyle.h" + +#define GLOBALDOC_OPTIONS 1 +#define PROJECTDOC_OPTIONS 2 + + +class ASStringIterator : public astyle::ASSourceIterator +{ +public: + + ASStringIterator(const QString &string); + virtual ~ASStringIterator(); + + virtual bool hasMoreLines() const; + virtual string nextLine(); + + +private: + + QString _content; + QTextStream *_is; + +}; + +class AStyleWidget; + +class KDevFormatter : public astyle::ASFormatter +{ +public: + + KDevFormatter(const QMap<QString, QVariant>& options); + KDevFormatter( AStyleWidget * widget ); + QString indentString() const + { + return m_indentString; + } + +private: + bool predefinedStyle( const QString & style ); + +private: + QString m_indentString; +}; + + +#endif diff --git a/parts/astyle/astyle_part.cpp b/parts/astyle/astyle_part.cpp new file mode 100644 index 00000000..526af170 --- /dev/null +++ b/parts/astyle/astyle_part.cpp @@ -0,0 +1,541 @@ +#include "astyle_part.h" + +#include <qwhatsthis.h> +#include <qvbox.h> +#include <qtextstream.h> +#include <qpopupmenu.h> +#include <kdeversion.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <kdevgenericfactory.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kparts/part.h> +#include <kparts/partmanager.h> +#include <ktexteditor/editinterface.h> +#include <ktexteditor/document.h> +#include <ktexteditor/viewcursorinterface.h> +#include <ktexteditor/selectioninterface.h> +#include <kprogress.h> +#include <kdevcore.h> +#include <kdevapi.h> +#include <kdevpartcontroller.h> +#include <kdevplugininfo.h> +#include <configwidgetproxy.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kfiledialog.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <qlineedit.h> +#include <qregexp.h> + +#include "astyle_widget.h" +#include "astyle_adaptor.h" + +static const KDevPluginInfo data("kdevastyle"); + +namespace { + const char* defaultFormatExtensions = "*.cpp *.h *.hpp,*.c *.h,*.cxx *.hxx,*.c++ *.h++,*.cc *.hh,*.C *.H,*.diff ,*.inl,*.java,*.moc,*.patch,*.tlh,*.xpm"; +} + + +typedef KDevGenericFactory<AStylePart> AStyleFactory; +K_EXPORT_COMPONENT_FACTORY( libkdevastyle, AStyleFactory( data ) ) + +AStylePart::AStylePart(QObject *parent, const char *name, const QStringList &) + : KDevSourceFormatter(&data, parent, name ? name : "AStylePart") +{ + setInstance(AStyleFactory::instance()); + + setXMLFile("kdevpart_astyle.rc"); + + formatTextAction = new KAction(i18n("&Reformat Source"), 0, this, SLOT(beautifySource()), actionCollection(), "edit_astyle"); + formatTextAction->setEnabled(false); + formatTextAction->setToolTip(i18n("Reformat source")); + formatTextAction->setWhatsThis(i18n("<b>Reformat source</b><p>Source reformatting functionality using <b>astyle</b> library. " + "Also available in <b>New Class</b> and <b>Subclassing</b> wizards.")); + + formatFileAction = new KAction(i18n("Format files"), 0, this, SLOT(formatFilesSelect()), actionCollection(), "tools_astyle"); + formatFileAction->setEnabled(false); + formatFileAction->setToolTip(i18n("Format files")); + formatFileAction->setWhatsThis(i18n("<b>Fomat files</b><p>Formatting functionality using <b>astyle</b> library. " + "Also available in <b>New Class</b> and <b>Subclassing</b> wizards.")); + formatFileAction->setEnabled ( true ); + + m_configProxy = new ConfigWidgetProxy(core()); + m_configProxy->createGlobalConfigPage(i18n("Formatting"), GLOBALDOC_OPTIONS, info()->icon()); + m_configProxy->createProjectConfigPage(i18n("Formatting"), PROJECTDOC_OPTIONS, info()->icon()); + + + connect(m_configProxy, SIGNAL(insertConfigWidget(const KDialogBase* ,QWidget*,unsigned int)), this, SLOT(insertConfigWidget(const KDialogBase*,QWidget*,unsigned int))); + + connect(partController(), SIGNAL(activePartChanged(KParts::Part*)), this, SLOT(activePartChanged(KParts::Part*))); + + connect( core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), this, SLOT(contextMenu(QPopupMenu *, const Context *)) ); + + loadGlobal(); + //use the globals first, project level will override later.. + m_project=m_global; + m_projectExtensions = m_globalExtensions; + setExtensions(m_globalExtensions.join("\n"),false); + + // maybe there is a file open already + activePartChanged( partController()->activePart() ); + +} + +void AStylePart::loadGlobal() +{ +// 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,FillForce=0,IndentBlocks=0,IndentBrackets=0,IndentCases=0,IndentClasses=1,IndentLabels=1,IndentNamespaces=1,IndentPreprocessors=0,IndentSwitches=1,KeepBlocks=1,KeepStatements=1,MaxStatement=40,MinConditional=-1,PadOperators=0,PadParenthesesIn=1,PadParenthesesOut=1,PadParenthesesUn=1,"); + m_globalExtensions=QStringList::split(",",config->readEntry("Extensions",defaultFormatExtensions)); + + QStringList pairs = QStringList::split( ",", options); + QStringList::Iterator it; + for ( it = pairs.begin(); it != pairs.end(); ++it ) { + QStringList bits = QStringList::split( "=", (*it) ); + m_global[bits[0]] = bits[1]; + } + + +// for (QMap<QString, QVariant>::iterator iter = m_global.begin();iter != m_global.end();iter++) +// { +// kdDebug(9009) << "load: " <<iter.key() << "="<< iter.data() << endl; +// } +} + +void AStylePart::saveGlobal() +{ + QString options; + for (QMap<QString, QVariant>::iterator iter = m_global.begin();iter != m_global.end();iter++) + { +// kdDebug(9009) <<"saveGlobal" <<iter.key() << "="<< iter.data() << endl; + options += iter.key(); + options += "="; + options += iter.data().toString(); + options += ","; + } +// for (QMap<QString, QVariant>::iterator iter = m_project.begin();iter != m_project.end();iter++) +// { +// kdDebug(9009) << "project before: " <<iter.key() << "="<< iter.data() << endl; +// } + + KConfig *config = kapp->config(); + config->setGroup("AStyle"); + config->writeEntry("Options",options); + config->writeEntry("Extensions",m_globalExtensions.join(",")); + + config->sync(); +// for (QMap<QString, QVariant>::iterator iter = m_global.begin();iter != m_global.end();iter++) +// { +// kdDebug(9009) << "global after: " <<iter.key() << "="<< iter.data() << endl; +// } +// for (QMap<QString, QVariant>::iterator iter = m_project.begin();iter != m_project.end();iter++) +// { +// kdDebug(9009) << "project after: " <<iter.key() << "="<< iter.data() << endl; +// } +} + +AStylePart::~AStylePart() +{ + saveGlobal(); + delete m_configProxy; +} + +void AStylePart::beautifySource() +{ + KTextEditor::EditInterface *iface + = dynamic_cast<KTextEditor::EditInterface*>(partController()->activePart()); + if (!iface) + return; + + bool has_selection = false; + + KTextEditor::SelectionInterface *sel_iface + = dynamic_cast<KTextEditor::SelectionInterface*>(partController()->activePart()); + if (sel_iface && sel_iface->hasSelection()) + has_selection = true; + + //if there is a selection, we only format it. + ASStringIterator is(has_selection ? sel_iface->selection() : iface->text()); + KDevFormatter formatter(m_project); + + formatter.init(&is); + + QString output; + QTextStream os(&output, IO_WriteOnly); + + // put the selection back to the same indent level. + // taking note of the config options. + unsigned int indentCount=0; + QString indentWith(""); + if ( has_selection){ + QString original = sel_iface->selection(); + for (;indentCount<original.length();indentCount++){ + QChar ch = original[indentCount]; + if ( ch.isSpace()){ + if ( ch == QChar('\n') || ch == QChar('\r')){ + indentWith=""; + } + else{ + indentWith+=original[indentCount]; + } + } + else{ + break; + } + } + + int wsCount = m_project["FillCount"].toInt(); + if (m_project["Fill"].toString() == "Tabs") + { + // tabs and wsCount spaces to be a tab + QString replace; + for (int i =0;i<wsCount;i++) + replace+=' '; + + indentWith=indentWith.replace(replace, QChar('\t')); + indentWith=indentWith.remove(' '); + } else + { + if ( m_project["FillForce"].toBool()){ + //convert tabs to spaces + QString replace; + for (int i =0;i<wsCount;i++) + replace+=' '; + + indentWith=indentWith.replace(QChar('\t'),replace); + } + } + } + + while (formatter.hasMoreLines()){ + if ( has_selection ){ + os << indentWith; + } + os << QString::fromUtf8(formatter.nextLine().c_str()) << endl; + } + + uint col = 0; + uint line = 0; + + if(has_selection) //there was a selection, so only change the part of the text related to it + { + //remove the final newline character, unless it should be there + if ( !sel_iface->selection().endsWith( "\n" ) ) + output.setLength(output.length()-1); + + sel_iface->removeSelectedText(); + cursorPos( partController()->activePart(), &col, &line ); + iface->insertText( col, line, output); + + return; + } + + cursorPos( partController()->activePart(), &col, &line ); + + iface->setText( output ); + + setCursorPos( partController()->activePart(), col, line ); +} + +void AStylePart::insertConfigWidget(const KDialogBase *dlg, QWidget *page, unsigned int pageNo) +{ + switch (pageNo) + { + case GLOBALDOC_OPTIONS: + { + AStyleWidget *w = new AStyleWidget(this, true, page, "astyle config widget"); + connect(dlg, SIGNAL(okClicked()), w, SLOT(accept())); + break; + } + case PROJECTDOC_OPTIONS: + { + AStyleWidget *w = new AStyleWidget(this, false, page, "astyle config widget"); + connect(dlg, SIGNAL(okClicked()), w, SLOT(accept())); + break; + } + } +} + +QString AStylePart::getGlobalExtensions(){ + QString values = m_globalExtensions.join("\n"); + return values.stripWhiteSpace(); +} +QString AStylePart::getProjectExtensions(){ + QString values = m_projectExtensions.join("\n"); + return values.stripWhiteSpace(); +} + + +/** + * Extensions from the widget passed in. + * We preserve the order, so common extensions will + * end up at the top + * @param ext + */ +void AStylePart::setExtensions ( QString ext, bool global ) +{ + kdDebug(9009) << "setExtensions " << ext<<endl; + if ( global){ + m_globalExtensions.clear(); + m_globalExtensions=QStringList::split ( QRegExp("\n"), ext ); + } + else{ + m_searchExtensions.clear(); + m_projectExtensions.clear(); + m_projectExtensions = QStringList::split ( QRegExp("\n"), ext ); + QStringList bits = QStringList::split(QRegExp("\\s+"),ext); + for ( QStringList::Iterator iter = bits.begin(); iter != bits.end(); iter++ ) + { + QString ending=*iter; + if ( ending.startsWith ( "*" ) ) + { + if (ending.length() ==1 ){ + // special case.. any file. + m_searchExtensions.insert(ending, ending); + } + else{ + m_searchExtensions.insert( ending.mid( 1 ), ending); + } + } + else + { + m_searchExtensions.insert(ending, ending); + } + } + } +} + +void AStylePart::activePartChanged ( KParts::Part *part ) +{ + bool enabled = false; + + KParts::ReadWritePart *rw_part = dynamic_cast<KParts::ReadWritePart*> ( part ); + + if ( rw_part ) + { + KTextEditor::EditInterface *iface = dynamic_cast<KTextEditor::EditInterface*> ( rw_part ); + + if ( iface ) + { + // check for the everything case.. + if ( m_searchExtensions.find ( "*" ) == m_searchExtensions.end() ) + { + QString extension = rw_part->url().path(); + int pos = extension.findRev ( '.' ); + if ( pos >= 0 ) + { + extension = extension.mid ( pos ); + enabled = ( m_searchExtensions.find ( extension ) != m_searchExtensions.end() ); + } + } + else + { + enabled = true; + } + } + } + + formatTextAction->setEnabled ( enabled ); +} + +QString AStylePart::formatSource( const QString text, AStyleWidget * widget, const QMap<QString, QVariant>& options ) +{ + ASStringIterator is(text); + KDevFormatter * formatter = ( widget)? new KDevFormatter( widget ) : new KDevFormatter(options); + + formatter->init(&is); + + QString output; + QTextStream os(&output, IO_WriteOnly); + + while ( formatter->hasMoreLines() ) + os << QString::fromUtf8( formatter->nextLine().c_str() ) << endl; + + delete formatter; + + return output; +} + +void AStylePart::cursorPos( KParts::Part *part, uint * line, uint * col ) +{ + if (!part || !part->inherits("KTextEditor::Document")) return; + + KTextEditor::ViewCursorInterface *iface = dynamic_cast<KTextEditor::ViewCursorInterface*>(part->widget()); + if (iface) + { + iface->cursorPositionReal( line, col ); + } +} + +void AStylePart::setCursorPos( KParts::Part *part, uint line, uint col ) +{ + if (!part || !part->inherits("KTextEditor::Document")) return; + + KTextEditor::ViewCursorInterface *iface = dynamic_cast<KTextEditor::ViewCursorInterface*>(part->widget()); + if (iface) + { + iface->setCursorPositionReal( line, col ); + } +} + +QString AStylePart::formatSource( const QString text ) +{ + return formatSource(text, 0, m_project); +} + +QString AStylePart::indentString( ) const +{ + KDevFormatter formatter(m_project); + return formatter.indentString(); +} + +void AStylePart::contextMenu(QPopupMenu *popup, const Context *context) +{ + if (context->hasType( Context::EditorContext )) + { + popup->insertSeparator(); + int id = popup->insertItem( i18n("Format selection"), this, SLOT(beautifySource()) ); + popup->setWhatsThis(id, i18n("<b>Format</b><p>Formats the current selection, if possible")); + } + else if ( context->hasType( Context::FileContext )){ + const FileContext *ctx = static_cast<const FileContext*>(context); + m_urls = ctx->urls(); + + popup->insertSeparator(); + int id = popup->insertItem( i18n("Format files"), this, SLOT(formatFiles()) ); + popup->setWhatsThis(id, i18n("<b>Format files</b><p>Formats selected files if possible")); + + } +} + +void AStylePart::restorePartialProjectSession(const QDomElement * el) +{ + kdDebug(9009) << "Load project" << endl; + QDomElement style = el->namedItem("AStyle").toElement(); + + if (style.attribute("FStyle", "GLOBAL") == "GLOBAL") + { + m_project = m_global; + m_project["FStyle"] = "GLOBAL"; + m_projectExtensions=m_globalExtensions; + } + else + { + for (QMap<QString, QVariant>::iterator iter = m_global.begin();iter != m_global.end();iter++) + { + m_project[iter.key()] = style.attribute(iter.key(),iter.data().toString()); + } + + QDomElement exten = el->namedItem("Extensions").toElement(); + QString ext = exten.attribute("ext").simplifyWhiteSpace(); + if ( ext.isEmpty()){ + ext=defaultFormatExtensions; + } + setExtensions(ext.replace(QChar(','), QChar('\n')),false); + } +} + + +void AStylePart::savePartialProjectSession(QDomElement * el) +{ + QDomDocument domDoc = el->ownerDocument(); + if (domDoc.isNull()) + return; + + QDomElement style = domDoc.createElement("AStyle"); + style.setAttribute("FStyle", m_project["FStyle"].toString()); + if (m_project["FStyle"] != "GLOBAL") + { + for (QMap<QString, QVariant>::iterator iter = m_project.begin();iter != m_project.end();iter++) + { + style.setAttribute(iter.key(),iter.data().toString()); + } + QDomElement exten = domDoc.createElement ( "Extensions" ); + exten.setAttribute ( "ext", m_projectExtensions.join(",").simplifyWhiteSpace() ); + el->appendChild(exten); + } + el->appendChild(style); +} + +void AStylePart::formatFilesSelect(){ + m_urls.clear(); + QStringList filenames = KFileDialog::getOpenFileNames ( QString::null, getProjectExtensions(),0,"Select files to format" ); + + for(QStringList::Iterator it = filenames.begin(); it != filenames.end();it++){ + m_urls << *it; + } + formatFiles(); +} + + +/** + * Format the selected files with the current style. + */ +void AStylePart::formatFiles() +{ + KURL::List::iterator it = m_urls.begin(); + while ( it != m_urls.end() ) + { + kdDebug ( 9009 ) << "Selected " << ( *it ).pathOrURL() << endl; + ++it; + } + + uint processed = 0; + for ( uint fileCount = 0; fileCount < m_urls.size(); fileCount++ ) + { + QString fileName = m_urls[fileCount].pathOrURL(); + + bool found = false; + for ( QMap<QString, QString>::Iterator it = m_searchExtensions.begin(); it != m_searchExtensions.end(); ++it ) + { + QRegExp re ( it.data(), true, true ); + if ( re.search ( fileName ) == 0 && ( uint ) re.matchedLength() == fileName.length() ) + { + found = true; + break; + } + } + + if ( found ) + { + QString backup = fileName + "#"; + QFile fin ( fileName ); + QFile fout ( backup ); + if ( fin.open ( IO_ReadOnly ) ) + { + if ( fout.open ( IO_WriteOnly ) ) + { + QString fileContents ( fin.readAll() ); + fin.close(); + QTextStream outstream ( &fout ); + outstream << formatSource ( fileContents ); + fout.close(); + QDir().rename ( backup, fileName ); + processed++; + } + else + { + KMessageBox::sorry ( 0, i18n ( "Not able to write %1" ).arg ( backup ) ); + } + } + else + { + KMessageBox::sorry ( 0, i18n ( "Not able to read %1" ).arg ( fileName ) ); + } + } + } + if ( processed != 0 ) + { + KMessageBox::information ( 0, i18n ( "Processed %1 files ending with extensions %2" ).arg ( processed ).arg(getProjectExtensions().stripWhiteSpace()) ); + } + m_urls.clear(); + +} + + +#include "astyle_part.moc" diff --git a/parts/astyle/astyle_part.h b/parts/astyle/astyle_part.h new file mode 100644 index 00000000..bf572dcc --- /dev/null +++ b/parts/astyle/astyle_part.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2001 Matthias H�zer-Klpfel <mhk@caldera.de> + */ + + +#ifndef __KDEVPART_ASTYLE_H__ +#define __KDEVPART_ASTYLE_H__ + +class KDialogBase; +#include <kdevsourceformatter.h> +#include <kaction.h> +#include <kparts/part.h> +#include <kdevplugin.h> +#include <kdebug.h> +#include <qmap.h> +#include <qvariant.h> + +class AStyleWidget; +class QPopupMenu; +class Context; +class ConfigWidgetProxy; + +class AStylePart : public KDevSourceFormatter +{ + Q_OBJECT + +public: + + AStylePart(QObject *parent, const char *name, const QStringList &); + ~AStylePart(); + + QString formatSource(const QString text, AStyleWidget * widget, const QMap<QString, QVariant>& options); + virtual QString formatSource(const QString text); + QString indentString() const; + void saveGlobal(); + void setExtensions(QString ext, bool global); + QString getProjectExtensions(); + QString getGlobalExtensions(); + void restorePartialProjectSession(const QDomElement * el); + void savePartialProjectSession(QDomElement * el); + + QMap<QString, QVariant>& getProjectOptions(){return m_project;} + QMap<QString, QVariant>& getGlobalOptions(){return m_global;} + + +private slots: + + void activePartChanged(KParts::Part *part); + void beautifySource(); + void formatFiles(); + void formatFilesSelect(); + void insertConfigWidget(const KDialogBase *dlg, QWidget *page, unsigned int pageNo); + void contextMenu(QPopupMenu *popup, const Context *context); + +private: + + void cursorPos( KParts::Part *part, uint * col, uint * line ); + void setCursorPos( KParts::Part *part, uint col, uint line ); + + void loadGlobal(); + + ConfigWidgetProxy *m_configProxy; + KAction *formatTextAction; + KAction *formatFileAction; + + // the configurable options. + QMap<QString, QVariant> m_project; + QMap<QString, QVariant> m_global; + QStringList m_projectExtensions; + QStringList m_globalExtensions; + QMap<QString, QString> m_searchExtensions; + KURL::List m_urls; +}; + + +#endif diff --git a/parts/astyle/astyle_widget.cpp b/parts/astyle/astyle_widget.cpp new file mode 100644 index 00000000..0622b91b --- /dev/null +++ b/parts/astyle/astyle_widget.cpp @@ -0,0 +1,346 @@ +#include "astyle_part.h" +#include "astyle_widget.h" + +#include <qradiobutton.h> +#include <qtabwidget.h> +#include <qmultilineedit.h> +#include <qbuttongroup.h> +#include <qpushbutton.h> +#include <qcheckbox.h> +#include <qspinbox.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kdevcore.h> + + +AStyleWidget::AStyleWidget(AStylePart * part, bool global, QWidget *parent, const char *name) + : AStyleConfig(parent, name), m_part(part), isGlobalWidget(global) +{ + // which style changed - disable the other pages. + connect(StyleGroup, SIGNAL(clicked(int)), this, SLOT(styleChanged())); + connect(ConfigTabs, SIGNAL(currentChanged(QWidget*)), this, SLOT(styleChanged()) ); + + connect(FillingGroup, SIGNAL(clicked(int)), this, SLOT(styleChanged())); + connect(Fill_ForceTabs, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Fill_TabCount, SIGNAL(valueChanged(int)), this, SLOT(styleChanged())); + connect(Fill_SpaceCount, SIGNAL(valueChanged(int)), this, SLOT(styleChanged())); + + connect(BracketGroup, SIGNAL(clicked(int)), this, SLOT(styleChanged())); + connect(Brackets_CloseHeaders, SIGNAL(clicked()), this, SLOT(styleChanged())); + + connect(Indent_Switches, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Indent_Cases, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Indent_Classes, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Indent_Brackets, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Indent_Namespaces, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Indent_Labels, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Indent_Blocks, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Indent_Preprocessors, SIGNAL(clicked()), this, SLOT(styleChanged())); + + connect(Continue_MaxStatement, SIGNAL(valueChanged(int)), this, SLOT(styleChanged())); + connect(Continue_MinConditional, SIGNAL(valueChanged(int)), this, SLOT(styleChanged())); + + connect(Block_Break, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Block_BreakAll, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Block_IfElse, SIGNAL(clicked()), this, SLOT(styleChanged())); + + connect(Pad_ParenthesesIn, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Pad_ParenthesesOut, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Pad_ParenthesesUn, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Pad_Operators, SIGNAL(clicked()), this, SLOT(styleChanged())); + + connect(Keep_Statements, SIGNAL(clicked()), this, SLOT(styleChanged())); + connect(Keep_Blocks, SIGNAL(clicked()), this, SLOT(styleChanged())); + + + QMap<QString, QVariant> option; + if ( isGlobalWidget){ + Style_Global->hide(); + option = m_part->getGlobalOptions(); + } + else{ + Style_Global->show(); + option = m_part->getProjectOptions(); + } + + // style + QString s = option["FStyle"].toString(); + // fake the id so we disable the other pages. + int id=0; + if (s == "ANSI") id=1; + if (s == "KR") id=2; + if (s == "Linux") id=3; + if (s == "GNU") id=4; + if (s == "JAVA") id=5; + if (s == "GLOBAL") id = 6; + StyleGroup->setButton(id); + + if ( isGlobalWidget ){ + GeneralExtension->setText(m_part->getGlobalExtensions()); + GeneralExtension->setEnabled(true); + globalOptions=true; + } + else{ + if ( id == 6){ + GeneralExtension->setText(m_part->getGlobalExtensions()); + GeneralExtension->setEnabled(false); + globalOptions=true; + } + else{ + GeneralExtension->setText(m_part->getProjectExtensions()); + GeneralExtension->setEnabled(true); + globalOptions=false; + } + } + + m_lastExt=GeneralExtension->text(); + + if (s == "UserDefined" || s =="GLOBAL" ) + { + int wsCount = option["FillCount"].toInt(); + if (option["Fill"].toString() == "Tabs") + { + Fill_Tabs->setChecked(true); + Fill_TabCount->setValue(wsCount); + Fill_TabCount->setEnabled(true); + Fill_ForceTabs->setChecked(option["FillForce"].toBool()); + Fill_ForceTabs->setEnabled(true); + } + else + { + Fill_Spaces->setChecked(true); + Fill_SpaceCount->setValue(wsCount); + Fill_SpaceCount->setEnabled(true); + Fill_ConvertTabs->setChecked(option["FillForce"].toBool()); + Fill_ConvertTabs->setEnabled(true); + } + + Fill_EmptyLines->setChecked(option["FillEmptyLines"].toBool()); + + // indent + Indent_Switches->setChecked(option["IndentSwitches"].toBool()); + Indent_Cases->setChecked(option["IndentCases"].toBool()); + Indent_Classes->setChecked(option["IndentClasses"].toBool()); + Indent_Brackets->setChecked(option["IndentBrackets"].toBool()); + Indent_Namespaces->setChecked(option["IndentNamespaces"].toBool()); + Indent_Labels->setChecked(option["IndentLabels"].toBool()); + Indent_Blocks->setChecked(option["IndentBlocks"].toBool()); + Indent_Preprocessors->setChecked(option["IndentPreprocessors"].toBool()); + + // contiuation + Continue_MaxStatement->setValue(option["MaxStatement"].toInt()); + Continue_MinConditional->setValue(option["MinConditional"].toInt()); + + // brackets + s = option["Brackets"].toString(); + if (s == "Break") + Brackets_Break->setChecked(true); + else if (s == "Attach") + Brackets_Attach->setChecked(true); + else if (s == "Linux") + Brackets_Linux->setChecked(true); + else + Brackets_None->setChecked(true); + + Brackets_CloseHeaders->setChecked(option["BracketsCloseHeaders"].toBool()); + + Block_Break->setChecked(option["BlockBreak"].toBool()); + Block_BreakAll->setChecked(option["BlockBreakAll"].toBool()); + Block_IfElse->setChecked(option["BlockIfElse"].toBool()); + + // padding + Pad_ParenthesesIn->setChecked(option["PadParenthesesIn"].toBool()); + Pad_ParenthesesOut->setChecked(option["PadParenthesesOut"].toBool()); + Pad_ParenthesesUn->setChecked(option["PadParenthesesUn"].toBool()); + + Pad_Operators->setChecked(option["PadOperators"].toBool()); + + // oneliner + Keep_Statements->setChecked(option["KeepStatements"].toBool()); + Keep_Blocks->setChecked(option["KeepBlocks"].toBool()); + } + + + styleChanged(); +} + + +AStyleWidget::~AStyleWidget() +{ +} + + +void AStyleWidget::accept() +{ + QMap<QString, QVariant>* m_option; + if ( isGlobalWidget){ + m_option = &(m_part->getGlobalOptions()); + m_part->setExtensions(GeneralExtension->text(),true); + } + else{ + m_option = &(m_part->getProjectOptions()); + m_part->setExtensions(GeneralExtension->text(),false); + } + + + // style + if (Style_ANSI->isChecked()) + (*m_option)["FStyle"] = "ANSI"; + else if (Style_KR->isChecked()) + (*m_option)["FStyle"] = "KR"; + else if (Style_Linux->isChecked()) + (*m_option)["FStyle"] = "Linux"; + else if (Style_GNU->isChecked()) + (*m_option)["FStyle"] = "GNU"; + else if (Style_JAVA->isChecked()) + (*m_option)["FStyle"] = "JAVA"; + else if (Style_Global->isChecked()){ + QMap<QString,QVariant>& global = m_part->getGlobalOptions(); + QMap<QString,QVariant>& project = m_part->getProjectOptions(); + project=global; + project["FStyle"]="GLOBAL"; + } + else if (Style_UserDefined->isChecked()) + { + (*m_option)["FStyle"] = "UserDefined"; + + // fill + if (Fill_Tabs->isChecked()) + { + (*m_option)["Fill"] = "Tabs"; + (*m_option)["FillCount"] = Fill_TabCount->value(); + (*m_option)["FillForce"] = Fill_ForceTabs->isChecked(); + } + else + { + (*m_option)["Fill"] = "Spaces"; + (*m_option)["FillCount"] = Fill_SpaceCount->value(); + (*m_option)["FillForce"] = Fill_ConvertTabs->isChecked(); + } + + (*m_option)["FillEmptyLines"] = Fill_EmptyLines->isChecked(); + + // indent + (*m_option)["IndentSwitches"] = Indent_Switches->isChecked(); + (*m_option)["IndentCases"] = Indent_Cases->isChecked(); + (*m_option)["IndentClasses"] = Indent_Classes->isChecked(); + (*m_option)["IndentBrackets"] = Indent_Brackets->isChecked(); + (*m_option)["IndentNamespaces"] = Indent_Namespaces->isChecked(); + (*m_option)["IndentLabels"] = Indent_Labels->isChecked(); + (*m_option)["IndentBlocks"] = Indent_Blocks->isChecked(); + (*m_option)["IndentPreprocessors"] = Indent_Preprocessors->isChecked(); + + // continuation + (*m_option)["MaxStatement"] = Continue_MaxStatement->value(); + (*m_option)["MinConditional"] = Continue_MinConditional->value(); + + // brackets + if ( Brackets_None->isChecked()) + (*m_option)["Brackets"] = "None"; + else if (Brackets_Break->isChecked()) + (*m_option)["Brackets"] = "Break"; + else if (Brackets_Attach->isChecked()) + (*m_option)["Brackets"] = "Attach"; + else if (Brackets_Linux->isChecked()) + (*m_option)["Brackets"] = "Linux"; + + (*m_option)["BracketsCloseHeaders"] = Brackets_CloseHeaders->isChecked(); + + // blocks + (*m_option)["BlockBreak"] = Block_Break->isChecked(); + (*m_option)["BlockBreakAll"] = Block_BreakAll->isChecked(); + (*m_option)["BlockIfElse"] = Block_IfElse->isChecked(); + + // padding + (*m_option)["PadParenthesesIn"] = Pad_ParenthesesIn->isChecked(); + (*m_option)["PadParenthesesOut"] = Pad_ParenthesesOut->isChecked(); + (*m_option)["PadParenthesesUn"] = Pad_ParenthesesUn->isChecked(); + + (*m_option)["PadOperators"] = Pad_Operators->isChecked(); + + // oneliner + (*m_option)["KeepStatements"] = Keep_Statements->isChecked(); + (*m_option)["KeepBlocks"] = Keep_Blocks->isChecked(); + } + + if ( isGlobalWidget){ + QMap<QString, QVariant>& project = m_part->getProjectOptions(); + if ( project["FStyle"] == "GLOBAL"){ + project = m_part->getGlobalOptions(); + project["FStyle"] = "GLOBAL"; + } + 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; +// } + +} + +/** + * Change the sample formatting text depending on what tab is selected. + * + * @param id Tab selected + */ +void AStyleWidget::styleChanged( ) +{ + // disable the tabs for predefined sample + // only user define id==0, enables the other tabs + ConfigTabs->setTabEnabled(tab_2, Style_UserDefined->isChecked()); + ConfigTabs->setTabEnabled(tab_3, Style_UserDefined->isChecked()); + ConfigTabs->setTabEnabled(tab_4, Style_UserDefined->isChecked()); + + int id = ConfigTabs->currentPageIndex(); + + StyleExample->clear(); + + 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}\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 = "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; + + switch(id){ + case 1: + StyleExample->setText( m_part->formatSource( bracketSample, this,m_part->getProjectOptions() ) ); + break; + case 2: + StyleExample->setText( m_part->formatSource( indentSample, this,m_part->getProjectOptions() ) ); + break; + case 3: + StyleExample->setText( m_part->formatSource( formattingSample, this,m_part->getProjectOptions() ) ); + break; + default: + { + if ( Style_Global->isChecked() ){ + StyleExample->setText( m_part->formatSource( styleSample, 0, m_part->getGlobalOptions()) ); + } + else + { + StyleExample->setText( m_part->formatSource( styleSample, this, m_part->getProjectOptions() ) ); + } + } + } + + if ( Style_Global->isChecked()){ + if ( !globalOptions){ + m_lastExt = GeneralExtension->text(); + GeneralExtension->setEnabled ( false ); + GeneralExtension->setText ( m_part->getGlobalExtensions() ); + globalOptions=!globalOptions; + } + } + else{ + if ( globalOptions){ + GeneralExtension->setEnabled ( true ); + GeneralExtension->setText ( m_lastExt ); + globalOptions=!globalOptions; + } + } +} + +#include "astyle_widget.moc" diff --git a/parts/astyle/astyle_widget.h b/parts/astyle/astyle_widget.h new file mode 100644 index 00000000..ac779985 --- /dev/null +++ b/parts/astyle/astyle_widget.h @@ -0,0 +1,36 @@ +#ifndef __ASTYLE_WIDGET_H__ +#define __ASTYLE_WIDGET_H__ + +#include "astyleconfig.h" + +class AStylePart; +class KDevPart; + + +class AStyleWidget : public AStyleConfig +{ + Q_OBJECT + +public: + + AStyleWidget( AStylePart * part, bool global, QWidget *parent=0, const char *name=0 ); + ~AStyleWidget(); + + +public slots: + + void accept(); + + +private slots: + void styleChanged(); + +private: + AStylePart * m_part; + bool isGlobalWidget; + QString m_lastExt; + bool globalOptions; +}; + + +#endif diff --git a/parts/astyle/astyleconfig.ui b/parts/astyle/astyleconfig.ui new file mode 100644 index 00000000..38063bb6 --- /dev/null +++ b/parts/astyle/astyleconfig.ui @@ -0,0 +1,1332 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>AStyleConfig</class> +<widget class="QWidget"> + <property name="name"> + <cstring>AStyleConfig</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>711</width> + <height>722</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="caption"> + <string>Artistic Style Configuration</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QTabWidget" row="0" column="0"> + <property name="name"> + <cstring>ConfigTabs</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>&General</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>StyleGroup</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>350</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>32767</height> + </size> + </property> + <property name="title"> + <string>&Style</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Style_UserDefined</cstring> + </property> + <property name="text"> + <string>&User defined</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="buttonGroupId"> + <number>0</number> + </property> + <property name="toolTip" stdset="0"> + <string>Select options from other tabs.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Style_ANSI</cstring> + </property> + <property name="text"> + <string>&ANSI</string> + </property> + <property name="buttonGroupId"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>ANSI style formatting/indenting. +Brackets Break +Use 4 spaces +Indent Bracket=false +Indent Class=false +Indent Switch=false +Indent NameSpace=false</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Style_KR</cstring> + </property> + <property name="text"> + <string>&Kernighan && Ritchie</string> + </property> + <property name="buttonGroupId"> + <number>2</number> + </property> + <property name="toolTip" stdset="0"> + <string>Kernighan & Ritchie style formatting/indenting. +Brackets Attach +Use 4 spaces +Indent Class=false +Indent Switch=false +Indent Namespaces=false +</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Style_Linux</cstring> + </property> + <property name="text"> + <string>Linu&x</string> + </property> + <property name="buttonGroupId"> + <number>3</number> + </property> + <property name="toolTip" stdset="0"> + <string>Linux mode (8 spaces per indent, break definition-block brackets but attach command-block brackets). +Brackets Linux +Use 8 spaces +Indent Bracket=false +Indent Class=false +Indent Switch=false +Indent NameSpace=false</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Style_GNU</cstring> + </property> + <property name="text"> + <string>G&NU</string> + </property> + <property name="buttonGroupId"> + <number>4</number> + </property> + <property name="toolTip" stdset="0"> + <string>GNU style formatting/indenting. +Brackets Break +Use 2 spaces +Indent Block=true +Indent Bracket=false +Indent Class=false +Indent Switch=false +Indent NameSpace=false</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Style_JAVA</cstring> + </property> + <property name="text"> + <string>&JAVA</string> + </property> + <property name="buttonGroupId"> + <number>5</number> + </property> + <property name="toolTip" stdset="0"> + <string>Java mode, with standard java style formatting/indenting. +Java Style +Use 4 spaces +Brackets Attach +Indent Bracket=false +Indent Switch=false</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Style_Global</cstring> + </property> + <property name="text"> + <string>Use Global &Options</string> + </property> + <property name="buttonGroupId"> + <number>6</number> + </property> + <property name="toolTip" stdset="0"> + <string>Use the global defaults. See the menu: +Settings/Configure Kdevelop/Formatting.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>FrameFilesFormat</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Files to format</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QTextEdit"> + <property name="name"> + <cstring>GeneralExtension</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>*.c *.h +*.cpp *.hpp +*.C *.H +*.cxx *.hxx +*.cc *.hh +*.c++ *.h++ +*.inl *.tlh +*.moc *.xpm +*.diff *.patch +*.java</string> + </property> + <property name="wordWrap"> + <enum>WidgetWidth</enum> + </property> + <property name="toolTip" stdset="0"> + <string>Set the extensions of files that the +formatter will try to reformat. Use a +space separated list, e.g. *.cpp *.hpp. +Can use * on its own for any file.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Set the extensions of files that the +formatter will try to reformat. Use a +space separated list, e.g. *.cpp *.hpp. +Can use * on its own for any file.</string> + </property> + </widget> + </vbox> + </widget> + </vbox> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>Tab && Bra&ckets</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup" row="0" column="0"> + <property name="name"> + <cstring>FillingGroup</cstring> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>32767</height> + </size> + </property> + <property name="title"> + <string>&Filling</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="spacing"> + <number>20</number> + </property> + <widget class="QCheckBox" row="2" column="0"> + <property name="name"> + <cstring>Fill_EmptyLines</cstring> + </property> + <property name="text"> + <string>Fill empt&y lines</string> + </property> + <property name="toolTip" stdset="0"> + <string>Fill empty lines with the white space of their previous lines.</string> + </property> + </widget> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton" row="0" column="0"> + <property name="name"> + <cstring>Fill_Tabs</cstring> + </property> + <property name="text"> + <string>U&se tabs</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QSpinBox" row="1" column="2"> + <property name="name"> + <cstring>Fill_SpaceCount</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="value"> + <number>2</number> + </property> + <property name="toolTip" stdset="0"> + <string>Number of spaces to use per indent.</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="4"> + <property name="name"> + <cstring>Fill_ConvertTabs</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Con&vert tabs</string> + </property> + <property name="toolTip" stdset="0"> + <string>Convert tabs to spaces.</string> + </property> + </widget> + <spacer row="0" column="1" rowspan="2" colspan="1"> + <property name="name"> + <cstring>spacer13</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>34</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QRadioButton" row="1" column="0"> + <property name="name"> + <cstring>Fill_Spaces</cstring> + </property> + <property name="focusPolicy"> + <enum>NoFocus</enum> + </property> + <property name="text"> + <string>&Use spaces:</string> + </property> + </widget> + <widget class="QSpinBox" row="0" column="2"> + <property name="name"> + <cstring>Fill_TabCount</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="value"> + <number>4</number> + </property> + <property name="toolTip" stdset="0"> + <string>Number of spaces that will be converted to a tab. +The number of spaces per tab is controled by the editor.</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="4"> + <property name="name"> + <cstring>Fill_ForceTabs</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>F&orce tabs</string> + </property> + <property name="toolTip" stdset="0"> + <string>Force tabs to be used in areas Astyle would prefer to use spaces.</string> + </property> + </widget> + <spacer row="0" column="3" rowspan="2" colspan="1"> + <property name="name"> + <cstring>spacer13_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>21</height> + </size> + </property> + </spacer> + </grid> + </widget> + </grid> + </widget> + <widget class="QButtonGroup" row="1" column="0"> + <property name="name"> + <cstring>BracketGroup</cstring> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>32767</height> + </size> + </property> + <property name="title"> + <string>Brackets</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="spacing"> + <number>20</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Brackets_None</cstring> + </property> + <property name="text"> + <string>&No Change</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>The brackets will not be changed.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Brackets_Break</cstring> + </property> + <property name="text"> + <string>&Break</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Break brackets from pre-block code (i.e. ANSI C/C++ style).</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Brackets_Attach</cstring> + </property> + <property name="text"> + <string>&Attach</string> + </property> + <property name="toolTip" stdset="0"> + <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="QRadioButton"> + <property name="name"> + <cstring>Brackets_Linux</cstring> + </property> + <property name="text"> + <string>Linu&x style</string> + </property> + <property name="toolTip" stdset="0"> + <string>Break brackets from class/function declarations, +but attach brackets to pre-block command statements.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Brackets_CloseHeaders</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Brea&k closing headers</string> + </property> + <property name="toolTip" stdset="0"> + <string>Break brackets before closing headers (e.g. 'else', 'catch', ...) +from their immediately preceding closing brackets.</string> + </property> + </widget> + </vbox> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>&Indentation</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="1" column="0"> + <property name="name"> + <cstring>ContinueationGroup</cstring> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>32767</height> + </size> + </property> + <property name="title"> + <string>Contin&uation</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QSpinBox" row="0" column="1"> + <property name="name"> + <cstring>Continue_MaxStatement</cstring> + </property> + <property name="value"> + <number>40</number> + </property> + <property name="toolTip" stdset="0"> + <string>Indent a maximal # spaces in a continuous statement, +relative to the previous line.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>Maximum in statement:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Indent a maximal # spaces in a continuous statement, +relative to the previous line.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>TextLabel3</cstring> + </property> + <property name="text"> + <string>Minimum in conditional:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Indent a minimal # spaces in a continuous conditional +belonging to a conditional header.</string> + </property> + </widget> + <widget class="QSpinBox" row="1" column="1"> + <property name="name"> + <cstring>Continue_MinConditional</cstring> + </property> + <property name="specialValueText"> + <string>Twice current</string> + </property> + <property name="minValue"> + <number>-1</number> + </property> + <property name="value"> + <number>-1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Indent a minimal # spaces in a continuous conditional +belonging to a conditional header.</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>IndentGroup</cstring> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>32767</height> + </size> + </property> + <property name="title"> + <string>Indented &Entities</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Indent_Switches</cstring> + </property> + <property name="text"> + <string>&Switches</string> + </property> + <property name="toolTip" stdset="0"> + <string>Indent 'switch' blocks, so that the inner 'case XXX:' +headers are indented in relation to the switch block.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Indent_Cases</cstring> + </property> + <property name="text"> + <string>&Case statements</string> + </property> + <property name="toolTip" stdset="0"> + <string>Indent case blocks from the 'case XXX:' headers. +Case statements not enclosed in blocks are NOT indented.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Indent_Classes</cstring> + </property> + <property name="text"> + <string>Cla&sses</string> + </property> + <property name="toolTip" stdset="0"> + <string>Indent 'class' blocks, so that the inner 'public:', +'protected:' and 'private: headers are indented in +relation to the class block.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Indent_Brackets</cstring> + </property> + <property name="text"> + <string>&Brackets</string> + </property> + <property name="toolTip" stdset="0"> + <string>Add extra indentation to '{' and '}' block brackets.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Indent_Namespaces</cstring> + </property> + <property name="text"> + <string>&Namespaces</string> + </property> + <property name="toolTip" stdset="0"> + <string>Indent the contents of namespace blocks.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Indent_Labels</cstring> + </property> + <property name="text"> + <string>L&abels</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Indent labels so that they appear one indent less than +the current indentation level, rather than being +flushed completely to the left (which is the default).</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Indent_Blocks</cstring> + </property> + <property name="text"> + <string>Bloc&ks</string> + </property> + <property name="toolTip" stdset="0"> + <string>Add extra indentation entire blocks (including brackets).</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Indent_Preprocessors</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>#Prepr&ocessors</string> + </property> + <property name="toolTip" stdset="0"> + <string>Indent multi-line #define statements.</string> + </property> + </widget> + </vbox> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>For&matting</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup" row="0" column="0"> + <property name="name"> + <cstring>BlockGroup</cstring> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>32767</height> + </size> + </property> + <property name="title"> + <string>Blocks</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>Block_Break</cstring> + </property> + <property name="text"> + <string>&Break blocks</string> + </property> + <property name="toolTip" stdset="0"> + <string>Insert empty lines around unrelated blocks, labels, classes,... +Known problems: + +1. If a statement is NOT part of a block, +the following statements are all double spaced. +Statements enclosed in a block are formatted +correctly. + +2. Comments are broken from the block. +</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>Block_BreakAll</cstring> + </property> + <property name="text"> + <string>Break bl&ocks all</string> + </property> + <property name="toolTip" stdset="0"> + <string>Like --break-blocks, except also insert empty lines +around closing headers (e.g. 'else', 'catch', ...). + +Known problems: + +1. If a statement is NOT part of a block, +the following statements are all double spaced. +Statements enclosed in a block are formatted +correctly. + +2. Comments are broken from the block. +</string> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0"> + <property name="name"> + <cstring>Block_IfElse</cstring> + </property> + <property name="text"> + <string>Break i&f-else</string> + </property> + <property name="toolTip" stdset="0"> + <string>Break 'else if()' statements into two different lines.</string> + </property> + </widget> + </grid> + </widget> + <widget class="QButtonGroup" row="1" column="0"> + <property name="name"> + <cstring>PaddingGroup</cstring> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>32767</height> + </size> + </property> + <property name="title"> + <string>Padding</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Pad_ParenthesesIn</cstring> + </property> + <property name="text"> + <string>Add spa&ces inside parentheses</string> + </property> + <property name="toolTip" stdset="0"> + <string>Insert space padding around parenthesis on the inside only.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Pad_ParenthesesOut</cstring> + </property> + <property name="text"> + <string>A&dd spaces outside parentheses</string> + </property> + <property name="toolTip" stdset="0"> + <string>Insert space padding around parenthesis on the outside only.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Pad_ParenthesesUn</cstring> + </property> + <property name="text"> + <string>Remove &unnecessary spaces around parentheses</string> + </property> + <property name="toolTip" stdset="0"> + <string>Remove unnecessary space padding around parenthesis.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Pad_Operators</cstring> + </property> + <property name="text"> + <string>&Add spaces around operators</string> + </property> + <property name="toolTip" stdset="0"> + <string>Insert space padding around operators. +Once padded, operators stay padded. +There is no unpad operator option.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QGroupBox" row="2" column="0"> + <property name="name"> + <cstring>OneLinersGroup</cstring> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>32767</height> + </size> + </property> + <property name="title"> + <string>One Liners</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Keep_Statements</cstring> + </property> + <property name="text"> + <string>&Keep one-line statements</string> + </property> + <property name="toolTip" stdset="0"> + <string>Do not break lines containing multiple statements into +multiple single-statement lines.</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>Keep_Blocks</cstring> + </property> + <property name="text"> + <string>Keep o&ne-line blocks</string> + </property> + <property name="toolTip" stdset="0"> + <string>Do not break blocks residing completely on one line.</string> + </property> + </widget> + </vbox> + </widget> + </grid> + </widget> + </widget> + <widget class="QGroupBox" row="0" column="1"> + <property name="name"> + <cstring>GroupBox4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Example</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QMultiLineEdit" row="0" column="0"> + <property name="name"> + <cstring>StyleExample</cstring> + </property> + <property name="palette"> + <palette> + <active> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>220</red> + <green>220</green> + <blue>220</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>237</red> + <green>237</green> + <blue>237</blue> + </color> + <color> + <red>110</red> + <green>110</green> + <blue>110</blue> + </color> + <color> + <red>146</red> + <green>146</green> + <blue>146</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>217</red> + <green>220</green> + <blue>194</blue> + </color> + <color> + <red>220</red> + <green>220</green> + <blue>220</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>84</red> + <green>112</green> + <blue>152</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </active> + <disabled> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>220</red> + <green>220</green> + <blue>220</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>253</red> + <green>253</green> + <blue>253</blue> + </color> + <color> + <red>110</red> + <green>110</green> + <blue>110</blue> + </color> + <color> + <red>146</red> + <green>146</green> + <blue>146</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>217</red> + <green>220</green> + <blue>194</blue> + </color> + <color> + <red>220</red> + <green>220</green> + <blue>220</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>84</red> + <green>112</green> + <blue>152</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </disabled> + <inactive> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>220</red> + <green>220</green> + <blue>220</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>253</red> + <green>253</green> + <blue>253</blue> + </color> + <color> + <red>110</red> + <green>110</green> + <blue>110</blue> + </color> + <color> + <red>146</red> + <green>146</green> + <blue>146</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>217</red> + <green>220</green> + <blue>194</blue> + </color> + <color> + <red>220</red> + <green>220</green> + <blue>220</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>84</red> + <green>112</green> + <blue>152</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </inactive> + </palette> + </property> + <property name="font"> + <font> + <family>misc-fixed</family> + </font> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <property name="text"> + <string></string> + </property> + <property name="undoDepth"> + <number>0</number> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>Fill_Tabs</sender> + <signal>toggled(bool)</signal> + <receiver>Fill_TabCount</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Fill_Tabs</sender> + <signal>toggled(bool)</signal> + <receiver>Fill_ForceTabs</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Fill_Spaces</sender> + <signal>toggled(bool)</signal> + <receiver>Fill_SpaceCount</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Fill_Spaces</sender> + <signal>toggled(bool)</signal> + <receiver>Fill_ConvertTabs</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Brackets_Attach</sender> + <signal>toggled(bool)</signal> + <receiver>Brackets_CloseHeaders</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Brackets_Linux</sender> + <signal>toggled(bool)</signal> + <receiver>Brackets_CloseHeaders</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<tabstops> + <tabstop>ConfigTabs</tabstop> + <tabstop>Style_UserDefined</tabstop> + <tabstop>Fill_Tabs</tabstop> + <tabstop>Fill_TabCount</tabstop> + <tabstop>Fill_ForceTabs</tabstop> + <tabstop>Fill_SpaceCount</tabstop> + <tabstop>Fill_ConvertTabs</tabstop> + <tabstop>Fill_EmptyLines</tabstop> + <tabstop>Brackets_None</tabstop> + <tabstop>Brackets_CloseHeaders</tabstop> + <tabstop>Indent_Switches</tabstop> + <tabstop>Indent_Cases</tabstop> + <tabstop>Indent_Classes</tabstop> + <tabstop>Indent_Brackets</tabstop> + <tabstop>Indent_Namespaces</tabstop> + <tabstop>Indent_Labels</tabstop> + <tabstop>Indent_Blocks</tabstop> + <tabstop>Indent_Preprocessors</tabstop> + <tabstop>Continue_MaxStatement</tabstop> + <tabstop>Continue_MinConditional</tabstop> + <tabstop>Block_Break</tabstop> + <tabstop>Block_BreakAll</tabstop> + <tabstop>Block_IfElse</tabstop> + <tabstop>Pad_ParenthesesIn</tabstop> + <tabstop>Pad_ParenthesesOut</tabstop> + <tabstop>Pad_ParenthesesUn</tabstop> + <tabstop>Pad_Operators</tabstop> + <tabstop>Keep_Statements</tabstop> + <tabstop>Keep_Blocks</tabstop> + <tabstop>StyleExample</tabstop> +</tabstops> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<slots> + <slot>allFiles()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> diff --git a/parts/astyle/kdevastyle.desktop b/parts/astyle/kdevastyle.desktop new file mode 100644 index 00000000..261e2edf --- /dev/null +++ b/parts/astyle/kdevastyle.desktop @@ -0,0 +1,82 @@ +[Desktop Entry] +Type=Service +Exec=blubb +Comment=A plugin for formatting of sourcecode according to a specified set of rules. When loaded it is found in the Tools menu. +Comment[ca]=Un connector per a donar format al codi font d'acord a una sèrie de regles especificades. Quan està carregat apareixerà en el menú Eines. +Comment[da]=Et plugin til at formatere kildekode ifølge et angivet sæt regler. Når det er indlæst er det i værktøjsmenuen. +Comment[de]=Ein Modul zur Formatierung der Quelltexte nach vorgegebenen Regeln. Ist das Modul geladen, kann es über das Menü "Werkzeuge" aufgerufen werden. +Comment[el]=Ένα πρόσθετο για τη μορφοποίηση του πηγαίου κώδικα σύμφωνα με το ορισμένο σύνολο κανόνων. Όταν φορτωθεί μπορεί να βρεθεί στο μενού εργαλείων. +Comment[es]=Un complemento para dar formato al código fuente de acuerdo una serie de reglas especificadas. Cuando está cargado, aparece en el menú Herramientas. +Comment[et]=Plugin lähtekoodi vormindamiseks vastavalt konkreetsetele reeglitele. Kasutamisel leiab selle tööriistade menüüst. +Comment[eu]=Iturburu kodea emandako arau sorten arabera formateatuko da. Kargatzean Tresnak menuan aurkituko duzu. +Comment[fa]=وصلهای برای قالببندی کد منبع طبق یک سری قوانین مشخصشده. در هنگام بارگذاری در گزینگان ابزار یافت میشود. +Comment[fr]=Un module externe pour le formatage du code source selon un ensemble de règles spécifié. Lorsqu'il est chargé, ce module externe se trouve dans le menu « Outils ». +Comment[gl]=Unha extensión para formatear código seguindo un conxunto de regras. Cando se carga atópase no menú Ferramentas. +Comment[hu]=Bővítőmodul forráskód formázásához, megadott szabályok alapján. Az Eszközök menüből érhető el, ha be van töltve. +Comment[it]=Un plugin per formattare il codice sorgente secondo uno specifico insieme di regole. Quando sarà caricato lo troverai nel menu Strumenti. +Comment[ja]=指定された規則にソースコードを書式化するためのプラグイン。読み込まれるとツールメニューで見つかります。 +Comment[ms]=Plugin untuk memformat kod sumber mengikut set peraturan yang ditetapkan. Apabila dimuatkan ia berada di menu Alatan. +Comment[nds]=En Moduul för't Borntextformateren na angeven Regeln. Wenn dat Moduul laadt is, lett sik dat binnen dat Warktüüchmenü finnen. +Comment[ne]=नियमको निर्दिष्ट सेट अनुसार स्रोतसङ्केतको ढाँचाबद्धताका लागि प्लगइन । लोड भएपछि यो उपकरण मेनुमा फेला पार्न सकिन्छ । +Comment[nl]=Een plugin om broncode te formatteren volgens een speciale set regels. Te vinden onder het menu Gereedschap. +Comment[pl]=Wtyczka do formatowania kodu źródłowego zgodnie z podanymi zasadami. Po wczytaniu pojawia się w menu Narzędzia. +Comment[pt]=Um 'plugin' para a formatação do código-fonte de acordo com um conjunto específico de regras. Quando é carregado, encontrar-se-á no menu Ferramentas. +Comment[pt_BR]=Um plug-in para formatação do código fonte de acordo com um conjunto específico de regras. Quando carregado é encontrado no menu Ferramentas. +Comment[ru]=Модуль для форматирования кода по установленным правилам. +Comment[sk]=Modul pre formátovanie zdrojového kódu podľa špecifických pravidiel.Po načítaní ho nájdete v menu Nástroje. +Comment[sr]=Прикључак за форматирање изворног кôда према прецизираном скупу правила. Када је учитан, налази се у менију „Алати“. +Comment[sr@Latn]=Priključak za formatiranje izvornog kôda prema preciziranom skupu pravila. Kada je učitan, nalazi se u meniju „Alati“. +Comment[sv]=Ett insticksprogram för att formatera källkod enligt en given uppsättning regler. När det laddats finns det i verktygsmenyn. +Comment[ta]=மூல குறிமுறை வடிவத்தை மாற்றும் சொருகிக்கு சில குறிப்பிட்ட விதிமுறைகள் உள்ளது. ஏற்றியபின் இதனை கருவிப்பட்டியில் காணலாம். +Comment[tg]=Модул барои қолабгузории код аз рӯи қонунҳои гузошта шуда. +Comment[tr]=Belli kurallara göre kaynak kodu biçimlendirmeye yarayan bir eklenti. Yüklendiğinde Araçlar menüsünde bulunabilir. +Comment[zh_CN]=一个按照指定规则格式化源代码的插件。启动后显示在工具菜单。 +Comment[zh_TW]=一個根據特定規則將程式源碼格式化的外掛程式。載入後可以在工具選單中找到。 +Name=KDevAStyle +Name[da]=KDevelop en stil +Name[de]=Artistic-Style-Unterstützung (KDevelop) +Name[hi]=के-डेव-ए-स्टाइल +Name[nds]=Kodestil-Ünnerstütten för KDevelop +Name[pl]=KDevStylA +Name[sk]=KDev štýl +Name[sv]=KDevelop A-stil +Name[zh_TW]=KDevelop AStyle +GenericName=Source Code Formatter +GenericName[ca]=Formatador de codi font +GenericName[da]=Kildekode-formatering +GenericName[de]=Quelltext-Formatierer +GenericName[el]=Μορφοποιητής πηγαίου κώδικα +GenericName[es]=Formateador de código fuente +GenericName[et]=Lähtekoodi vormindaja +GenericName[eu]=Iturburu kode formateatzailea +GenericName[fa]=قالبدهندۀ کد منبع +GenericName[fr]=Formatage de code source +GenericName[gl]=Formateador de código +GenericName[hi]=स्रोत कोड फ़ॉर्मेटर +GenericName[hu]=Forráskód-formázó +GenericName[it]=Formattatore del codice sorgente +GenericName[ja]=ソースコードフォーマッタ +GenericName[ms]=Pemformat Kod Sumber +GenericName[nds]=Borntext-Formateren +GenericName[ne]=स्रोत सङ्केत ढाँचाबद्धक +GenericName[nl]=Broncode formatteren +GenericName[pl]=Formatowanie kodu źródłowego +GenericName[pt]=Formatador de Código Fonte +GenericName[pt_BR]=Formatador de Código Fonte +GenericName[ru]=Форматирование исходного кода +GenericName[sk]=Formátovač zdrojového kódu +GenericName[sl]=Oblikovalec izvorne kode +GenericName[sr]=Форматер изворног кода +GenericName[sr@Latn]=Formater izvornog koda +GenericName[sv]=Källkodsformatering +GenericName[ta]=மூல குறியை வடிவமைப்பவர் +GenericName[tg]=Қолабгузори коди берунӣ +GenericName[tr]=Kaynak Kodu Biçimlendirici +GenericName[zh_CN]=源代码格式化 +GenericName[zh_TW]=程式源碼格式器 +Icon=kdevelop +ServiceTypes=KDevelop/SourceFormatter +X-KDE-Library=libkdevastyle +X-KDevelop-Version=5 +X-KDevelop-Scope=Project +X-KDevelop-Properties=CDevelopment,CPPDevelopment,JavaDevelopment diff --git a/parts/astyle/kdevpart_astyle.rc b/parts/astyle/kdevpart_astyle.rc new file mode 100644 index 00000000..69037425 --- /dev/null +++ b/parts/astyle/kdevpart_astyle.rc @@ -0,0 +1,17 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="KDevAStyle" version="6"> +<MenuBar> + <Menu name="edit"> + <Action name="edit_astyle" group="edit_astyle"/> + </Menu> + <Menu name="tools" > + <Action name="tools_astyle" group="tools_astyle"/> + </Menu> +</MenuBar> +<ToolBar name="astyleToolBar"> + <text>Astyle Toolbar</text> + <Action name="tools_astyle" group="tools_astyle"/> + <Action name="edit_astyle" group="edit_astyle"/> +</ToolBar> + +</kpartgui> |