diff options
Diffstat (limited to 'tools/designer/plugins')
68 files changed, 14278 insertions, 0 deletions
diff --git a/tools/designer/plugins/cppeditor/common.cpp b/tools/designer/plugins/cppeditor/common.cpp new file mode 100644 index 000000000..661b85b0b --- /dev/null +++ b/tools/designer/plugins/cppeditor/common.cpp @@ -0,0 +1,111 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "editorinterfaceimpl.h" +#include "languageinterfaceimpl.h" +#include "preferenceinterfaceimpl.h" +#include "projectsettingsinterfaceimpl.h" +#include "sourcetemplateinterfaceimpl.h" + +class CommonInterface : public TQComponentInformationInterface +{ +public: + CommonInterface(); + virtual ~CommonInterface(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** ); + Q_REFCOUNT; + + TQString name() const { return "C++"; } + TQString description() const { return "C++ Integration"; } + TQString version() const { return "0.1"; } + TQString author() const { return "Trolltech AS"; } + +private: + LanguageInterfaceImpl *langIface; + PreferenceInterfaceImpl *prefIface; + ProjectSettingsInterfaceImpl *proIface; + SourceTemplateInterfaceImpl *srcIface; + +}; + +CommonInterface::CommonInterface() +{ + langIface = new LanguageInterfaceImpl( this ); + langIface->addRef(); + prefIface = new PreferenceInterfaceImpl( this ); + prefIface->addRef(); + proIface = new ProjectSettingsInterfaceImpl( this ); + proIface->addRef(); + srcIface = new SourceTemplateInterfaceImpl; + srcIface->addRef(); +} + +CommonInterface::~CommonInterface() +{ + langIface->release(); + prefIface->release(); + proIface->release(); + srcIface->release(); +} + +TQRESULT CommonInterface::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)this; + else if ( uuid == IID_QComponentInformation ) + *iface = (TQComponentInformationInterface*)this; + else if ( uuid == IID_Editor ) + *iface = new EditorInterfaceImpl; + else if ( uuid == IID_Language ) + *iface = langIface; + else if ( uuid == IID_Preference ) + *iface = prefIface; + else if ( uuid == IID_ProjectSettings ) + *iface = proIface; + else if ( uuid == IID_SourceTemplate ) + *iface = srcIface; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + + +Q_EXPORT_COMPONENT() +{ + Q_CREATE_INSTANCE( CommonInterface ) +} diff --git a/tools/designer/plugins/cppeditor/cppbrowser.cpp b/tools/designer/plugins/cppeditor/cppbrowser.cpp new file mode 100644 index 000000000..169e30dd5 --- /dev/null +++ b/tools/designer/plugins/cppeditor/cppbrowser.cpp @@ -0,0 +1,78 @@ +/********************************************************************** +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "cppbrowser.h" +#include <private/qrichtext_p.h> +#include <qprocess.h> +#include <qmainwindow.h> +#include <qstatusbar.h> +#include <editor.h> + +CppEditorBrowser::CppEditorBrowser( Editor *e ) + : EditorBrowser( e ) +{ +} + +void CppEditorBrowser::showHelp( const TQString &w ) +{ + TQString word( w ); + if ( word[ 0 ] == 'Q' ) { + if ( word[ (int)word.length() - 1 ] == '&' || + word[ (int)word.length() - 1 ] == '*' ) + word.remove( word.length() - 1, 1 ); + word = word.lower() + ".html"; + TQStringList lst; + lst << "assistant" << "-file" << word; + TQProcess proc( lst ); + proc.start(); + return; + } + + if ( word.find( '(' ) != -1 ) { + TQString txt = "::" + word.left( word.find( '(' ) ); + TQTextDocument *doc = curEditor->document(); + TQTextParagraph *p = doc->firstParagraph(); + while ( p ) { + if ( p->string()->toString().find( txt ) != -1 ) { + curEditor->setCursorPosition( p->paragId(), 0 ); + return; + } + p = p->next(); + } + } + + TQMainWindow *mw = ::qt_cast<TQMainWindow*>(curEditor->topLevelWidget()); + if ( mw ) + mw->statusBar()->message( tr( "Nothing available for '%1'" ).arg( w ), 1500 ); +} diff --git a/tools/designer/plugins/cppeditor/cppbrowser.h b/tools/designer/plugins/cppeditor/cppbrowser.h new file mode 100644 index 000000000..065802500 --- /dev/null +++ b/tools/designer/plugins/cppeditor/cppbrowser.h @@ -0,0 +1,50 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef CPPBROWSER_H +#define CPPBROWSER_H + +#include <browser.h> + +class CppEditorBrowser : public EditorBrowser +{ + Q_OBJECT + +public: + CppEditorBrowser( Editor *e ); + void showHelp( const TQString &word ); + +}; + +#endif diff --git a/tools/designer/plugins/cppeditor/cppcompletion.cpp b/tools/designer/plugins/cppeditor/cppcompletion.cpp new file mode 100644 index 000000000..97f226f28 --- /dev/null +++ b/tools/designer/plugins/cppeditor/cppcompletion.cpp @@ -0,0 +1,220 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "cppcompletion.h" +#include <qobject.h> +#include <qmetaobject.h> +#include <qobjectlist.h> +#include <qregexp.h> + +CppEditorCompletion::CppEditorCompletion( Editor *e ) + : EditorCompletion( e ) +{ +} + +bool CppEditorCompletion::doObjectCompletion( const TQString &objName ) +{ + if ( !ths ) + return FALSE; + TQString object( objName ); + int i = -1; + if ( ( i = object.findRev( "->" ) ) != -1 ) + object = object.mid( i + 2 ); + if ( ( i = object.findRev( "." ) ) != -1 ) + object = object.mid( i + 1 ); + object = object.simplifyWhiteSpace(); + TQObject *obj = 0; + if ( ths->name() == object || object == "this" ) { + obj = ths; + } else { + obj = ths->child( object ); + } + + if ( !obj ) + return FALSE; + + TQValueList<CompletionEntry> lst; + + if ( obj->children() ) { + for ( TQObjectListIt cit( *obj->children() ); cit.current(); ++cit ) { + TQString s( cit.current()->name() ); + if ( s.find( " " ) == -1 && s.find( "qt_" ) == -1 && s.find( "unnamed" ) == -1 ) { + CompletionEntry c; + c.type = "variable"; + c.text = s; + c.prefix = ""; + lst << c; + } + } + } + + TQStrList props = obj->metaObject()->propertyNames( TRUE ); + for ( TQPtrListIterator<char> pit( props ); pit.current(); ++pit ) { + TQString f( pit.current() ); + TQChar c = f[ 0 ]; + f.remove( (uint)0, 1 ); + f.prepend( c.upper() ); + f.prepend( "set" ); + + CompletionEntry ce; + ce.type = "property"; + ce.text = f; + ce.postfix = "()"; + + if ( lst.find( ce ) == lst.end() ) + lst << ce; + } + + TQStrList slts = obj->metaObject()->slotNames( TRUE ); + for ( TQPtrListIterator<char> sit( slts ); sit.current(); ++sit ) { + TQString f( sit.current() ); + f = f.left( f.find( "(" ) ); + CompletionEntry c; + c.type = "slot"; + c.text = f; + c.postfix = "()"; + if ( lst.find( c ) == lst.end() ) + lst << c; + } + + if ( lst.isEmpty() ) + return FALSE; + + showCompletion( lst ); + return TRUE; +} + +TQValueList<TQStringList> CppEditorCompletion::functionParameters( const TQString &expr, TQChar &separator, + TQString &prefix, TQString &postfix ) +{ + Q_UNUSED( prefix ); + Q_UNUSED( postfix ); + separator = ','; + if ( !ths ) + return TQValueList<TQStringList>(); + TQString func; + TQString objName; + int i = -1; + + i = expr.findRev( "->" ); + if ( i == -1 ) + i = expr.findRev( "." ); + else + ++i; + if ( i == -1 ) { + i = expr.findRev( " " ); + + if ( i == -1 ) + i = expr.findRev( "\t" ); + else + objName = ths->name(); + + if ( i == -1 && expr[ 0 ] != ' ' && expr[ 0 ] != '\t' ) + objName = ths->name(); + } + + if ( !objName.isEmpty() ) { + func = expr.mid( i + 1 ); + func = func.simplifyWhiteSpace(); + } else { + func = expr.mid( i + 1 ); + func = func.simplifyWhiteSpace(); + TQString ex( expr ); + ex.remove( i, 0xFFFFFF ); + if ( ex[ (int)ex.length() - 1 ] == '-' ) + ex.remove( ex.length() - 1, 1 ); + int j = -1; + j = ex.findRev( "->" ); + if ( j == -1 ) + j = ex.findRev( "." ); + else + ++j; + if ( j == -1 ) { + j = ex.findRev( " " ); + + if ( j == -1 ) + j = ex.findRev( "\t" ); + else + objName = ths->name(); + + if ( j == -1 ) + objName = ths->name(); + } + objName = ex.mid( j + 1 ); + objName = objName.simplifyWhiteSpace(); + } + + TQObject *obj = 0; + if ( ths->name() == objName || objName == "this" ) { + obj = ths; + } else { + obj = ths->child( objName ); + } + + if ( !obj ) + return TQValueList<TQStringList>(); + + TQStrList slts = obj->metaObject()->slotNames( TRUE ); + for ( TQPtrListIterator<char> sit( slts ); sit.current(); ++sit ) { + TQString f( sit.current() ); + f = f.left( f.find( "(" ) ); + if ( f == func ) { + f = TQString( sit.current() ); + f.remove( (uint)0, f.find( "(" ) + 1 ); + f = f.left( f.find( ")" ) ); + TQStringList lst = TQStringList::split( ',', f ); + if ( !lst.isEmpty() ) { + TQValueList<TQStringList> l; + l << lst; + return l; + } + } + } + + const TQMetaProperty *prop = + obj->metaObject()-> + property( obj->metaObject()->findProperty( func[ 3 ].lower() + func.mid( 4 ), TRUE ), TRUE ); + if ( prop ) { + TQValueList<TQStringList> l; + l << TQStringList( prop->type() ); + return l; + } + + return TQValueList<TQStringList>(); +} + +void CppEditorCompletion::setContext( TQObject *this_ ) +{ + ths = this_; +} diff --git a/tools/designer/plugins/cppeditor/cppcompletion.h b/tools/designer/plugins/cppeditor/cppcompletion.h new file mode 100644 index 000000000..abc0c90ad --- /dev/null +++ b/tools/designer/plugins/cppeditor/cppcompletion.h @@ -0,0 +1,60 @@ +/********************************************************************** +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef CPPCOMPLETION_H +#define CPPCOMPLETION_H + +#include <completion.h> +#include <qguardedptr.h> + +class CppEditorCompletion : public EditorCompletion +{ + Q_OBJECT + +public: + CppEditorCompletion( Editor *e ); + +#if defined(Q_USING) + using EditorCompletion::doObjectCompletion; +#endif + bool doObjectCompletion( const TQString &object ); + TQValueList<TQStringList> functionParameters( const TQString &func, TQChar &, TQString &prefix, TQString &postfix ); + void setContext( TQObject *this_ ); + +private: + TQGuardedPtr<TQObject> ths; + +}; + +#endif diff --git a/tools/designer/plugins/cppeditor/cppeditor.cpp b/tools/designer/plugins/cppeditor/cppeditor.cpp new file mode 100644 index 000000000..399afa521 --- /dev/null +++ b/tools/designer/plugins/cppeditor/cppeditor.cpp @@ -0,0 +1,168 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "cppeditor.h" +#include "syntaxhighliter_cpp.h" +#include <cindent.h> +#include "cppcompletion.h" +#include "cppbrowser.h" +#include <parenmatcher.h> +#include <qsettings.h> +#include <qpopupmenu.h> +#include <qinputdialog.h> +#include <designerinterface.h> + +CppEditor::CppEditor( const TQString &fn, TQWidget *parent, const char *name, DesignerInterface *i ) + : Editor( fn, parent, name ), dIface( i ) +{ + if ( dIface ) + dIface->addRef(); + document()->setPreProcessor( new SyntaxHighlighter_CPP ); + document()->setIndent( (indent = new CIndent) ); + completion = new CppEditorCompletion( this ); + browser = new CppEditorBrowser( this ); + int j = 0; + while ( SyntaxHighlighter_CPP::keywords[ j ] != TQString::null ) + completion->addCompletionEntry( SyntaxHighlighter_CPP::keywords[ j++ ], 0, FALSE ); + configChanged(); +} + +CppEditor::~CppEditor() +{ + delete completion; + if ( dIface ) + dIface->release(); +} + +void CppEditor::configChanged() +{ + TQString path = "/Trolltech/CppEditor/"; + TQMap<TQString, ConfigStyle> styles = Config::readStyles( path ); + config()->styles = styles; + ( (SyntaxHighlighter_CPP*)document()->preProcessor() )->updateStyles( config()->styles ); + + completion->setEnabled( Config::completion( path ) ); + parenMatcher->setEnabled( Config::parenMatching( path ) ); + if ( Config::wordWrap( path ) ) { + if ( hScrollBarMode() != AlwaysOff ) { + document()->setFormatter( new TQTextFormatterBreakInWords ); + setHScrollBarMode( AlwaysOff ); + } + } else { + if ( hScrollBarMode() != AlwaysOn ) { + TQTextFormatterBreakWords *f = new TQTextFormatterBreakWords; + f->setWrapEnabled( FALSE ); + document()->setFormatter( f ); + setHScrollBarMode( AlwaysOn ); + } + } + + setFont( ( (SyntaxHighlighter_CPP*)document()->preProcessor() )->format( 0 )->font() ); + + indent->setTabSize( Config::indentTabSize( path ) ); + indent->setIndentSize( Config::indentIndentSize( path ) ); + indent->setKeepTabs( Config::indentKeepTabs( path ) ); + indent->setAutoIndent( Config::indentAutoIndent( path ) ); + if ( !Config::indentAutoIndent( path ) ) + document()->setIndent( 0 ); + else + document()->setIndent( indent ); + + document()->setTabStops( ( (SyntaxHighlighter_CPP*)document()->preProcessor() )->format( TQTextPreProcessor::Standard )->width( 'x' ) * Config::indentTabSize( path ) ); + + Editor::configChanged(); +} + +TQPopupMenu *CppEditor::createPopupMenu( const TQPoint &p ) +{ + TQPopupMenu *m = Editor::createPopupMenu( p ); + m->insertSeparator(); + int adddeclid = m->insertItem( tr( "Add Include File (in Declaration)..." ), this, SLOT( addInclDecl() ) ); + int addimplid = m->insertItem( tr( "Add Include File (in Implementation)..." ), this, SLOT( addInclImpl() ) ); + int addforid = m->insertItem( tr( "Add Forward Declaration..." ), this, SLOT( addForward() ) ); + if ( !dIface->currentForm() ) { + m->setItemEnabled( adddeclid, FALSE ); + m->setItemEnabled( addimplid, FALSE ); + m->setItemEnabled( addforid, FALSE ); + } + return m; +} + +void CppEditor::addInclDecl() +{ + if ( !dIface ) + return; + TQString s = TQInputDialog::getText( tr( "Add Include File (In Declaration)" ), + tr( "Input this using the format <b><include.h></b> or <b>\"include.h\"</b>" ) ); + if ( s.isEmpty() ) + return; + DesignerFormWindow *form = dIface->currentForm(); + TQStringList lst = form->declarationIncludes(); + lst << s; + form->setDeclarationIncludes( lst ); +} + +void CppEditor::addInclImpl() +{ + if ( !dIface ) + return; + TQString s = TQInputDialog::getText( tr( "Add Include File (In Implementation)" ), + tr( "Input this using the format <b><include.h></b> or <b>\"include.h\"</b>" ) ); + if ( s.isEmpty() ) + return; + DesignerFormWindow *form = dIface->currentForm(); + TQStringList lst = form->implementationIncludes(); + lst << s; + form->setImplementationIncludes( lst ); +} + +void CppEditor::addForward() +{ + if ( !dIface ) + return; + TQString s = TQInputDialog::getText( tr( "Add Forward Declaration" ), + tr( "Input this using the format <b>ClassName;</b>" ) ); + if ( s.isEmpty() ) + return; + DesignerFormWindow *form = dIface->currentForm(); + TQStringList lst = form->forwardDeclarations(); + lst << s; + form->setForwardDeclarations( lst ); +} + +void CppEditor::paste() +{ + Editor::paste(); + emit intervalChanged(); +} diff --git a/tools/designer/plugins/cppeditor/cppeditor.h b/tools/designer/plugins/cppeditor/cppeditor.h new file mode 100644 index 000000000..b0cd64fc2 --- /dev/null +++ b/tools/designer/plugins/cppeditor/cppeditor.h @@ -0,0 +1,78 @@ +/********************************************************************** +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef CPPEDITOR_H +#define CPPEDITOR_H + +#include <editor.h> + +class EditorCompletion; +class EditorBrowser; +struct DesignerInterface; +class CIndent; + +class CppEditor : public Editor +{ + Q_OBJECT + +public: + CppEditor( const TQString &fn, TQWidget *parent, const char *name, DesignerInterface *i ); + ~CppEditor(); + + virtual EditorCompletion *completionManager() { return completion; } + virtual EditorBrowser *browserManager() { return browser; } + void configChanged(); + + bool supportsBreakPoints() const { return FALSE; } +#if defined(Q_USING) + using TQTextEdit::createPopupMenu; +#endif + TQPopupMenu *createPopupMenu( const TQPoint &p ); + + void paste(); + +private slots: + void addInclDecl(); + void addInclImpl(); + void addForward(); + +protected: + EditorCompletion *completion; + EditorBrowser *browser; + DesignerInterface *dIface; + CIndent *indent; + +}; + +#endif diff --git a/tools/designer/plugins/cppeditor/cppeditor.pro b/tools/designer/plugins/cppeditor/cppeditor.pro new file mode 100644 index 000000000..391c1d73e --- /dev/null +++ b/tools/designer/plugins/cppeditor/cppeditor.pro @@ -0,0 +1,21 @@ +TEMPLATE = lib +CONFIG += qt warn_on plugin + +SOURCES += cppeditor.cpp syntaxhighliter_cpp.cpp cppcompletion.cpp editorinterfaceimpl.cpp languageinterfaceimpl.cpp common.cpp preferenceinterfaceimpl.cpp yyreg.cpp cppbrowser.cpp projectsettingsinterfaceimpl.cpp sourcetemplateinterfaceimpl.cpp +HEADERS += cppeditor.h syntaxhighliter_cpp.h cppcompletion.h editorinterfaceimpl.h languageinterfaceimpl.h preferenceinterfaceimpl.h yyreg.h cppbrowser.h projectsettingsinterfaceimpl.h sourcetemplateinterfaceimpl.h +FORMS = projectsettings.ui mainfilesettings.ui + +TARGET = cppeditor +DESTDIR = ../../../../plugins/designer +VERSION = 1.0.0 + +INCLUDEPATH += ../../interfaces ../../editor $$QT_BUILD_TREE/tools/designer/editor + +hpux-* { + LIBS += $$QT_BUILD_TREE/lib/libeditor.a +} else { + LIBS += -L$$QT_BUILD_TREE/lib -leditor +} + +target.path += $$plugins.path/designer +INSTALLS += target diff --git a/tools/designer/plugins/cppeditor/editorinterfaceimpl.cpp b/tools/designer/plugins/cppeditor/editorinterfaceimpl.cpp new file mode 100644 index 000000000..3816727dd --- /dev/null +++ b/tools/designer/plugins/cppeditor/editorinterfaceimpl.cpp @@ -0,0 +1,338 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "editorinterfaceimpl.h" +#include <viewmanager.h> +#include "cppeditor.h" +#include <private/qrichtext_p.h> +#include <qapplication.h> +#include "completion.h" +#include <designerinterface.h> +#include <qtimer.h> + +EditorInterfaceImpl::EditorInterfaceImpl() + : EditorInterface(), viewManager( 0 ), dIface( 0 ) +{ + updateTimer = new TQTimer( this ); + connect( updateTimer, SIGNAL( timeout() ), + this, SLOT( update() ) ); +} + +EditorInterfaceImpl::~EditorInterfaceImpl() +{ + updateTimer->stop(); + delete (ViewManager*)viewManager; + if ( dIface ) + dIface->release(); +} + +TQRESULT EditorInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)this; + else if ( uuid == IID_Editor ) + *iface = (EditorInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +TQWidget *EditorInterfaceImpl::editor( bool readonly, + TQWidget *parent, TQUnknownInterface *iface ) +{ + if ( !viewManager ) { + ( (EditorInterfaceImpl*)this )->viewManager = new ViewManager( parent, 0 ); + ( (EditorInterfaceImpl*)this )->viewManager->showMarkerWidget( FALSE ); + if ( iface ) + iface->queryInterface( IID_Designer, (TQUnknownInterface**) &dIface ); + CppEditor *e = new CppEditor( TQString::null, viewManager, "editor", dIface ); + e->setEditable( !readonly ); + e->installEventFilter( this ); + connect( e, SIGNAL( intervalChanged() ), this, SLOT( intervalChanged() ) ); + TQApplication::sendPostedEvents( viewManager, TQEvent::ChildInserted ); + } + return viewManager->currentView(); +} + +void EditorInterfaceImpl::setText( const TQString &txt ) +{ + if ( !viewManager || !viewManager->currentView() ) + return; + CppEditor *e = (CppEditor*)viewManager->currentView(); + disconnect( e, SIGNAL( modificationChanged( bool ) ), this, SLOT( modificationChanged( bool ) ) ); + e->setText( txt ); + e->setModified( FALSE ); + connect( e, SIGNAL( modificationChanged( bool ) ), this, SLOT( modificationChanged( bool ) ) ); +} + +TQString EditorInterfaceImpl::text() const +{ + if ( !viewManager || !viewManager->currentView() ) + return TQString::null; + TQString txt = ( (CppEditor*)viewManager->currentView() )->text(); + if ( !txt.isEmpty() && !txt.endsWith("\n") ) + txt += "\n"; + return txt; +} + +bool EditorInterfaceImpl::isUndoAvailable() const +{ + if ( !viewManager || !viewManager->currentView() ) + return FALSE; + return ( (CppEditor*)viewManager->currentView() )->isUndoAvailable(); +} + +bool EditorInterfaceImpl::isRedoAvailable() const +{ + if ( !viewManager || !viewManager->currentView() ) + return FALSE; + return ( (CppEditor*)viewManager->currentView() )->isRedoAvailable(); +} + +void EditorInterfaceImpl::undo() +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->undo(); +} + +void EditorInterfaceImpl::redo() +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->redo(); +} + +void EditorInterfaceImpl::cut() +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->cut(); +} + +void EditorInterfaceImpl::copy() +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->copy(); +} + +void EditorInterfaceImpl::paste() +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->paste(); +} + +void EditorInterfaceImpl::selectAll() +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->selectAll(); +} + +bool EditorInterfaceImpl::find( const TQString &expr, bool cs, bool wo, bool forward, bool startAtCursor ) +{ + if ( !viewManager || !viewManager->currentView() ) + return FALSE; + CppEditor *e = (CppEditor*)viewManager->currentView(); + if ( startAtCursor ) + return e->find( expr, cs, wo, forward ); + int dummy = 0; + return e->find( expr, cs, wo, forward, &dummy, &dummy ); +} + +bool EditorInterfaceImpl::replace( const TQString &find, const TQString &replace, bool cs, bool wo, + bool forward, bool startAtCursor, bool replaceAll ) +{ + if ( !viewManager || !viewManager->currentView() ) + return FALSE; + CppEditor *e = (CppEditor*)viewManager->currentView(); + bool ok = FALSE; + if ( startAtCursor ) { + ok = e->find( find, cs, wo, forward ); + } else { + int dummy = 0; + ok = e->find( find, cs, wo, forward, &dummy, &dummy ); + } + + if ( ok ) { + e->removeSelectedText(); + e->insert( replace, FALSE, FALSE ); + } + + if ( !replaceAll || !ok ) { + if ( ok ) + e->setSelection( e->textCursor()->paragraph()->paragId(), + e->textCursor()->index() - replace.length(), + e->textCursor()->paragraph()->paragId(), + e->textCursor()->index() ); + return ok; + } + + bool ok2 = TRUE; + while ( ok2 ) { + ok2 = e->find( find, cs, wo, forward ); + if ( ok2 ) { + e->removeSelectedText(); + e->insert( replace, FALSE, FALSE ); + } + } + + return TRUE; +} + +void EditorInterfaceImpl::gotoLine( int line ) +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->setCursorPosition( line, 0 ); +} + +void EditorInterfaceImpl::indent() +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->TQTextEdit::indent(); +} + +void EditorInterfaceImpl::splitView() +{ +#if 0 + if ( !viewManager || !viewManager->currentView() ) + return; + TQTextDocument *doc = ( (CppEditor*)viewManager->currentView() )->document(); + CppEditor *editor = new CppEditor( TQString::null, viewManager, "editor" ); + editor->setDocument( doc ); +#endif +} + +void EditorInterfaceImpl::scrollTo( const TQString &txt, const TQString & ) +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->sync(); + TQTextDocument *doc = ( (CppEditor*)viewManager->currentView() )->document(); + TQTextParagraph *p = doc->firstParagraph(); + while ( p ) { + if ( p->string()->toString().find( txt ) != -1 ) { + ( (CppEditor*)viewManager->currentView() )->setCursorPosition( p->paragId() + 2, 0 ); + break; + } + p = p->next(); + } + ( (CppEditor*)viewManager->currentView() )->setFocus(); +} + +void EditorInterfaceImpl::setContext( TQObject *this_ ) +{ + if ( !viewManager || !viewManager->currentView() ) + return; + ( (CppEditor*)viewManager->currentView() )->completionManager()->setContext( this_ ); +} + +void EditorInterfaceImpl::setError( int line ) +{ + if ( !viewManager ) + return; + viewManager->setError( line ); +} + +void EditorInterfaceImpl::readSettings() +{ + if ( !viewManager ) + return; + ( (CppEditor*)viewManager->currentView() )->configChanged(); +} + +void EditorInterfaceImpl::modificationChanged( bool m ) +{ + if ( viewManager && dIface ) + dIface->setModified( m, viewManager->currentView() ); +} + +void EditorInterfaceImpl::setModified( bool m ) +{ + if ( !viewManager ) + return; + ( (CppEditor*)viewManager->currentView() )->setModified( m ); +} + +bool EditorInterfaceImpl::isModified() const +{ + if ( !viewManager ) + return FALSE; + return ( (CppEditor*)viewManager->currentView() )->isModified(); +} + +bool EditorInterfaceImpl::eventFilter( TQObject *o, TQEvent *e ) +{ + if ( e->type() == TQEvent::KeyPress ) + updateTimer->stop(); + else if ( e->type() == TQEvent::FocusOut ) + update(); + + return TQObject::eventFilter( o, e ); +} + +int EditorInterfaceImpl::numLines() const +{ + if ( !viewManager || !viewManager->currentView() ) + return 0; + return ( (CppEditor*)viewManager->currentView() )->paragraphs(); +} + +void EditorInterfaceImpl::intervalChanged() +{ + if ( !dIface ) + return; + updateTimer->start( 2000, TRUE ); +} + +void EditorInterfaceImpl::update() +{ + if ( !dIface ) + return; + dIface->updateFunctionList(); +} + +void EditorInterfaceImpl::onBreakPointChange( TQObject *receiver, const char *slot ) +{ + if ( !viewManager ) + return; + connect( viewManager, SIGNAL( markersChanged() ), receiver, slot ); +} diff --git a/tools/designer/plugins/cppeditor/editorinterfaceimpl.h b/tools/designer/plugins/cppeditor/editorinterfaceimpl.h new file mode 100644 index 000000000..3ad411bd7 --- /dev/null +++ b/tools/designer/plugins/cppeditor/editorinterfaceimpl.h @@ -0,0 +1,107 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef EDITORINTERFACEIMPL_H +#define EDITORINTERFACEIMPL_H + +#include <editorinterface.h> +#include <qobject.h> +#include <qguardedptr.h> + +class TQTimer; +class ViewManager; +struct DesignerInterface; + +class EditorInterfaceImpl : public TQObject, public EditorInterface +{ + Q_OBJECT + +public: + EditorInterfaceImpl(); + virtual ~EditorInterfaceImpl(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** ); + Q_REFCOUNT; + + TQWidget *editor( bool readonly, TQWidget *parent, TQUnknownInterface *designerIface ); + + void setText( const TQString &txt ); + TQString text() const; + bool isUndoAvailable() const; + bool isRedoAvailable() const; + void undo(); + void redo(); + void cut(); + void copy(); + void paste(); + void selectAll(); + bool find( const TQString &expr, bool cs, bool wo, bool forward, bool startAtCursor ); + bool replace( const TQString &find, const TQString &replace, bool cs, bool wo, bool forward, bool startAtCursor, bool replaceAll ); + void gotoLine( int line ); + void indent(); + void scrollTo( const TQString &txt, const TQString &first ); + void splitView(); + void setContext( TQObject *this_ ); + void readSettings(); + + void setError( int line ); + void setStep( int ) {} + void clearStep() {} + void setModified( bool m ); + bool isModified() const; + void setMode( Mode ) {} + + int numLines() const; + void breakPoints( TQValueList<uint> & ) const {} + void setBreakPoints( const TQValueList<uint> & ) {} + void onBreakPointChange( TQObject *receiver, const char *slot ); + void clearStackFrame() {} + void setStackFrame( int ) {} + +protected: + bool eventFilter( TQObject*, TQEvent* ); + +private slots: + void modificationChanged( bool m ); + void intervalChanged(); + void update(); + +private: + TQGuardedPtr<ViewManager> viewManager; + DesignerInterface *dIface; + TQTimer *updateTimer; + +}; + +#endif diff --git a/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp b/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp new file mode 100644 index 000000000..9c2cd2053 --- /dev/null +++ b/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp @@ -0,0 +1,249 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "languageinterfaceimpl.h" +#include <qobject.h> +#include <designerinterface.h> +#include <qfile.h> +#include "yyreg.h" +#include <qmetaobject.h> + +LanguageInterfaceImpl::LanguageInterfaceImpl( TQUnknownInterface *outer ) + : parent( outer ), ref( 0 ) +{ +} + +ulong LanguageInterfaceImpl::addRef() +{ + return parent ? parent->addRef() : ref++; +} + +ulong LanguageInterfaceImpl::release() +{ + if ( parent ) + return parent->release(); + if ( !--ref ) { + delete this; + return 0; + } + return ref; +} + +TQRESULT LanguageInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface ) +{ + if ( parent ) + return parent->queryInterface( uuid, iface ); + + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)this; + else if ( uuid == IID_Language ) + *iface = (LanguageInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + + +class NormalizeObject : public TQObject +{ +public: + NormalizeObject() : TQObject() {} + static TQCString normalizeSignalSlot( const char *signalSlot ) { return TQObject::normalizeSignalSlot( signalSlot ); } +}; + +void LanguageInterfaceImpl::functions( const TQString &code, TQValueList<Function> *functionMap ) const +{ + TQValueList<CppFunction> l; + extractCppFunctions( code, &l ); + for ( TQValueList<CppFunction>::Iterator it = l.begin(); it != l.end(); ++it ) { + Function func; + func.name = (*it).prototype(); + func.name.remove( 0, (*it).returnType().length() ); + if ( func.name.find( "::" ) == -1 ) + continue; + func.name.remove( (uint)0, func.name.find( "::" ) + 2 ); + func.body = (*it).body(); + func.returnType = (*it).returnType(); + func.start = (*it).functionStartLineNum(); + func.end = (*it).closingBraceLineNum(); + functionMap->append( func ); + } +} + +TQString LanguageInterfaceImpl::createFunctionStart( const TQString &className, const TQString &func, + const TQString &returnType, + const TQString & ) +{ + return returnType + " " + className + "::" + func; +} + +TQStringList LanguageInterfaceImpl::definitions() const +{ + TQStringList lst; + lst << "Includes (in Implementation)" << "Includes (in Declaration)" << "Forward Declarations" << "Signals"; + return lst; +} + +TQStringList LanguageInterfaceImpl::definitionEntries( const TQString &definition, TQUnknownInterface *designerIface ) const +{ + DesignerInterface *iface = 0; + designerIface->queryInterface( IID_Designer, (TQUnknownInterface**) &iface ); + if ( !iface ) + return TQStringList(); + DesignerFormWindow *fw = iface->currentForm(); + if ( !fw ) + return TQStringList(); + TQStringList lst; + if ( definition == "Includes (in Implementation)" ) { + lst = fw->implementationIncludes(); + } else if ( definition == "Includes (in Declaration)" ) { + lst = fw->declarationIncludes(); + } else if ( definition == "Forward Declarations" ) { + lst = fw->forwardDeclarations(); + } else if ( definition == "Signals" ) { + lst = fw->signalList(); + } + iface->release(); + return lst; +} + +void LanguageInterfaceImpl::setDefinitionEntries( const TQString &definition, const TQStringList &entries, TQUnknownInterface *designerIface ) +{ + DesignerInterface *iface = 0; + designerIface->queryInterface( IID_Designer, (TQUnknownInterface**) &iface ); + if ( !iface ) + return; + DesignerFormWindow *fw = iface->currentForm(); + if ( !fw ) + return; + if ( definition == "Includes (in Implementation)" ) { + fw->setImplementationIncludes( entries ); + } else if ( definition == "Includes (in Declaration)" ) { + fw->setDeclarationIncludes( entries ); + } else if ( definition == "Forward Declarations" ) { + fw->setForwardDeclarations( entries ); + } else if ( definition == "Signals" ) { + fw->setSignalList( entries ); + } + iface->release(); +} + +TQString LanguageInterfaceImpl::createEmptyFunction() +{ + return "{\n\n}\n"; +} + +bool LanguageInterfaceImpl::supports( Support s ) const +{ + if ( s == ReturnType ) + return TRUE; + if ( s == ConnectionsToCustomSlots ) + return TRUE; + return FALSE; +} + +TQStringList LanguageInterfaceImpl::fileFilterList() const +{ + TQStringList f; + f << "C++ Files (*.cpp *.C *.cxx *.c++ *.c *.h *.H *.hpp *.hxx)"; + return f; + +} +TQStringList LanguageInterfaceImpl::fileExtensionList() const +{ + TQStringList f; + f << "cpp" << "C" << "cxx" << "c++" << "c" <<"h" << "H" << "hpp" << "hxx"; + return f; +} + +TQString LanguageInterfaceImpl::projectKeyForExtension( const TQString &extension ) const +{ + // also handle something like foo.ut.cpp + TQString ext = extension; + int i = ext.findRev('.'); + if ( i > -1 && i < (int)(ext.length()-1) ) + ext = ext.mid( i + 1 ); + if ( ext[ 0 ] == 'c' || ext[ 0 ] == 'C' ) + return "SOURCES"; + return "HEADERS"; +} + +void LanguageInterfaceImpl::sourceProjectKeys( TQStringList &keys ) const +{ + keys << "HEADERS" << "SOURCES"; +} + + class CheckObject : public TQObject +{ +public: + CheckObject() {} + bool checkConnectArgs( const char *signal, const char *member ) { return TQObject::checkConnectArgs( signal, 0, member ); } + +}; + +bool LanguageInterfaceImpl::canConnect( const TQString &signal, const TQString &slot ) +{ + CheckObject o; + return o.checkConnectArgs( signal.latin1(), slot.latin1() ); +} + +void LanguageInterfaceImpl::loadFormCode( const TQString &, const TQString &filename, + TQValueList<Function> &functions, + TQStringList &, + TQValueList<Connection> & ) +{ + TQFile f( filename ); + if ( !f.open( IO_ReadOnly ) ) + return; + TQTextStream ts( &f ); + TQString code( ts.read() ); + this->functions( code, &functions ); +} + +void LanguageInterfaceImpl::preferedExtensions( TQMap<TQString, TQString> &extensionMap ) const +{ + extensionMap.insert( "cpp", "C++ Source File" ); + extensionMap.insert( "h", "C++ Header File" ); +} + +TQStrList LanguageInterfaceImpl::signalNames( TQObject *obj ) const +{ + TQStrList sigs; + sigs = obj->metaObject()->signalNames( TRUE ); + sigs.remove( "destroyed()" ); + return sigs; +} diff --git a/tools/designer/plugins/cppeditor/languageinterfaceimpl.h b/tools/designer/plugins/cppeditor/languageinterfaceimpl.h new file mode 100644 index 000000000..af06a61ed --- /dev/null +++ b/tools/designer/plugins/cppeditor/languageinterfaceimpl.h @@ -0,0 +1,90 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef LANGUAGEINTERFACEIMPL_H +#define LANGUAGEINTERFACEIMPL_H + +#include <languageinterface.h> + +class LanguageInterfaceImpl : public LanguageInterface +{ +public: + LanguageInterfaceImpl( TQUnknownInterface *outer = 0 ); + + ulong addRef(); + ulong release(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** ); + + void functions( const TQString &code, TQValueList<Function> *funcs ) const; + void connections( const TQString &, TQValueList<Connection> * ) const {}; + TQString createFunctionStart( const TQString &className, const TQString &func, + const TQString &returnType, const TQString &access ); + TQStringList definitions() const; + TQStringList definitionEntries( const TQString &definition, TQUnknownInterface *designerIface ) const; + void setDefinitionEntries( const TQString &definition, const TQStringList &entries, TQUnknownInterface *designerIface ); + TQString createArguments( const TQString & ) { return TQString::null; } + TQString createEmptyFunction(); + bool supports( Support s ) const; + TQStringList fileFilterList() const; + TQStringList fileExtensionList() const; + void preferedExtensions( TQMap<TQString, TQString> &extensionMap ) const; + void sourceProjectKeys( TQStringList &keys ) const; + TQString projectKeyForExtension( const TQString &extension ) const; + TQString cleanSignature( const TQString &sig ) { return sig; } // #### implement me + void loadFormCode( const TQString &, const TQString &, + TQValueList<Function> &, + TQStringList &, + TQValueList<Connection> & ); + TQString formCodeExtension() const { return ".h"; } + bool canConnect( const TQString &signal, const TQString &slot ); + void compressProject( const TQString &, const TQString &, bool ) {} + TQString uncompressProject( const TQString &, const TQString & ) { return TQString::null; } + TQString aboutText() const { return ""; } + + void addConnection( const TQString &, const TQString &, + const TQString &, const TQString &, + TQString * ) {} + void removeConnection( const TQString &, const TQString &, + const TQString &, const TQString &, + TQString * ) {} + TQStrList signalNames( TQObject *obj ) const; + +private: + TQUnknownInterface *parent; + ulong ref; + +}; + +#endif diff --git a/tools/designer/plugins/cppeditor/mainfilesettings.ui b/tools/designer/plugins/cppeditor/mainfilesettings.ui new file mode 100644 index 000000000..80461afb2 --- /dev/null +++ b/tools/designer/plugins/cppeditor/mainfilesettings.ui @@ -0,0 +1,211 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>CppMainFile</class> +<comment>********************************************************************* +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +*********************************************************************</comment> +<widget class="TQDialog"> + <property name="name"> + <cstring>CppMainFile</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>308</width> + <height>283</height> + </rect> + </property> + <property name="caption"> + <string>Configure Main-File</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>TextLabel1</cstring> + </property> + <property name="text"> + <string>Filename:</string> + </property> + </widget> + <widget class="TQLineEdit" row="0" column="1"> + <property name="name"> + <cstring>editFileName</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>Main-Form:</string> + </property> + </widget> + <widget class="TQListBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>listForms</cstring> + </property> + </widget> + <widget class="TQLayoutWidget" row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonHelp</cstring> + </property> + <property name="text"> + <string>Help</string> + </property> + <property name="accel"> + <number>4144</number> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>OK</string> + </property> + <property name="accel"> + <number>0</number> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>Cancel</string> + </property> + <property name="accel"> + <number>0</number> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>CppMainFile</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>CppMainFile</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>listForms</sender> + <signal>selectionChanged()</signal> + <receiver>CppMainFile</receiver> + <slot>updateOkButton()</slot> + </connection> + <connection> + <sender>listForms</sender> + <signal>currentChanged(TQListBoxItem*)</signal> + <receiver>CppMainFile</receiver> + <slot>updateOkButton()</slot> + </connection> + <connection> + <sender>editFileName</sender> + <signal>textChanged(const TQString&)</signal> + <receiver>CppMainFile</receiver> + <slot>updateOkButton()</slot> + </connection> +</connections> +<includes> + <include location="local" impldecl="in implementation">mainfilesettings.ui.h</include> +</includes> +<forwards> + <forward>struct TQUnknownInterface;</forward> +</forwards> +<slots> + <slot>init()</slot> + <slot>setup( TQUnknownInterface * appIface )</slot> + <slot>updateOkButton()</slot> +</slots> +<pixmapinproject/> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/tools/designer/plugins/cppeditor/mainfilesettings.ui.h b/tools/designer/plugins/cppeditor/mainfilesettings.ui.h new file mode 100644 index 000000000..7dd3906c5 --- /dev/null +++ b/tools/designer/plugins/cppeditor/mainfilesettings.ui.h @@ -0,0 +1,36 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename slots use TQt Designer which will +** update this file, preserving your code. Create an init() slot in place of +** a constructor, and a destroy() slot in place of a destructor. +*****************************************************************************/ + +#include <designerinterface.h> + +void CppMainFile::init() +{ +} + +void CppMainFile::setup( TQUnknownInterface *appIface ) +{ + DesignerInterface *dIface = 0; + appIface->queryInterface( IID_Designer, (TQUnknownInterface**)&dIface ); + if ( !dIface ) + return; + TQStringList l = dIface->currentProject()->formNames(); + editFileName->setText( "main.cpp" ); + listForms->clear(); + listForms->insertStringList( l ); + listForms->setCurrentItem( 0 ); + updateOkButton(); + editFileName->setFocus(); + editFileName->selectAll(); +} + +void CppMainFile::updateOkButton() +{ + buttonOk->setEnabled( editFileName->text().length() > 0 && listForms->currentItem() != -1 ); +} + + diff --git a/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.cpp b/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.cpp new file mode 100644 index 000000000..b4f4a3328 --- /dev/null +++ b/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.cpp @@ -0,0 +1,102 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "preferenceinterfaceimpl.h" +#include <preferences.h> + +PreferenceInterfaceImpl::PreferenceInterfaceImpl( TQUnknownInterface *outer ) + : parent( outer ), + ref( 0 ), + cppEditorSyntax( 0 ) +{ +} + +PreferenceInterfaceImpl::~PreferenceInterfaceImpl() +{ +} + +ulong PreferenceInterfaceImpl::addRef() +{ + return parent ? parent->addRef() : ref++; +} + +ulong PreferenceInterfaceImpl::release() +{ + if ( parent ) + return parent->release(); + if ( !--ref ) { + delete this; + return 0; + } + return ref; +} + +TQRESULT PreferenceInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface ) +{ + if ( parent ) + return parent->queryInterface( uuid, iface ); + + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)this; + else if ( uuid == IID_Preference ) + *iface = (PreferenceInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +PreferenceInterface::Preference *PreferenceInterfaceImpl::preference() +{ + if ( !cppEditorSyntax ) { + cppEditorSyntax = new PreferencesBase( 0, "cppeditor_syntax" ); + ( (PreferencesBase*)cppEditorSyntax )->setPath( "/Trolltech/CppEditor/" ); + cppEditorSyntax->hide(); + } + Preference *pf = 0; + pf = new Preference; + pf->tab = cppEditorSyntax; + pf->title = "C++ Editor"; + pf->receiver = pf->tab; + pf->init_slot = SLOT( reInit() ); + pf->accept_slot = SLOT( save() ); + return pf; +} + +void PreferenceInterfaceImpl::deletePreferenceObject( Preference *p ) +{ + delete p; +} diff --git a/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.h b/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.h new file mode 100644 index 000000000..08ad3f55d --- /dev/null +++ b/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.h @@ -0,0 +1,64 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef PREFERENCEINTERFACEIMPL_H +#define PREFERENCEINTERFACEIMPL_H + +#include <preferenceinterface.h> +class TQWidget; + +class PreferenceInterfaceImpl : public PreferenceInterface +{ +public: + PreferenceInterfaceImpl( TQUnknownInterface *outer = 0 ); + virtual ~PreferenceInterfaceImpl(); + + ulong addRef(); + ulong release(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** ); + + Preference *preference(); + void connectTo( TQUnknownInterface * ) {} + void deletePreferenceObject( Preference * ); + +private: + TQUnknownInterface *parent; + int ref; + TQWidget *cppEditorSyntax; + +}; + +#endif + diff --git a/tools/designer/plugins/cppeditor/projectsettings.ui b/tools/designer/plugins/cppeditor/projectsettings.ui new file mode 100644 index 000000000..759e6af73 --- /dev/null +++ b/tools/designer/plugins/cppeditor/projectsettings.ui @@ -0,0 +1,347 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>CppProjectSettings</class> +<comment>********************************************************************* +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +*********************************************************************</comment> +<include location="local" implDecl="in declaration">projectsettings.ui.h</include> +<forward>struct TQUnknownInterface;</forward> +<variable>TQMap<TQString, TQString> config, libs, defines, includes;</variable> +<pixmapinproject/> +<layoutdefaults spacing="6" margin="11"/> +<widget class="TQWidget"> + <property name="name"> + <cstring>CppProjectSettings</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>373</width> + <height>191</height> + </rect> + </property> + <property name="caption"> + <string>Project Settings</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>TextLabel1</cstring> + </property> + <property name="text"> + <string>Config:</string> + </property> + </widget> + <spacer row="5" column="2"> + <property name="name"> + <cstring>Spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQLabel" row="3" column="0"> + <property name="name"> + <cstring>TextLabel2_2</cstring> + </property> + <property name="text"> + <string>Defines:</string> + </property> + </widget> + <widget class="TQLineEdit" row="3" column="2"> + <property name="name"> + <cstring>editDefines</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>Libs:</string> + </property> + </widget> + <widget class="TQLabel" row="4" column="0"> + <property name="name"> + <cstring>TextLabel2_3</cstring> + </property> + <property name="text"> + <string>Includepath:</string> + </property> + </widget> + <widget class="TQComboBox" row="3" column="1"> + <item> + <property name="text"> + <string>(all)</string> + </property> + </item> + <item> + <property name="text"> + <string>unix</string> + </property> + </item> + <item> + <property name="text"> + <string>win32</string> + </property> + </item> + <item> + <property name="text"> + <string>mac</string> + </property> + </item> + <property name="name"> + <cstring>comboDefines</cstring> + </property> + </widget> + <widget class="TQComboBox" row="4" column="1"> + <item> + <property name="text"> + <string>(all)</string> + </property> + </item> + <item> + <property name="text"> + <string>unix</string> + </property> + </item> + <item> + <property name="text"> + <string>win32</string> + </property> + </item> + <item> + <property name="text"> + <string>mac</string> + </property> + </item> + <property name="name"> + <cstring>comboInclude</cstring> + </property> + </widget> + <widget class="TQLineEdit" row="4" column="2"> + <property name="name"> + <cstring>editInclude</cstring> + </property> + </widget> + <widget class="TQLineEdit" row="2" column="2"> + <property name="name"> + <cstring>editLibs</cstring> + </property> + </widget> + <widget class="TQLineEdit" row="1" column="2"> + <property name="name"> + <cstring>editConfig</cstring> + </property> + </widget> + <widget class="TQComboBox" row="2" column="1"> + <item> + <property name="text"> + <string>(all)</string> + </property> + </item> + <item> + <property name="text"> + <string>unix</string> + </property> + </item> + <item> + <property name="text"> + <string>win32</string> + </property> + </item> + <item> + <property name="text"> + <string>mac</string> + </property> + </item> + <property name="name"> + <cstring>comboLibs</cstring> + </property> + </widget> + <widget class="TQComboBox" row="1" column="1"> + <item> + <property name="text"> + <string>(all)</string> + </property> + </item> + <item> + <property name="text"> + <string>unix</string> + </property> + </item> + <item> + <property name="text"> + <string>win32</string> + </property> + </item> + <item> + <property name="text"> + <string>mac</string> + </property> + </item> + <property name="name"> + <cstring>comboConfig</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>TextLabel3</cstring> + </property> + <property name="text"> + <string>Template:</string> + </property> + </widget> + <spacer row="0" column="2"> + <property name="name"> + <cstring>Spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQComboBox" row="0" column="1"> + <item> + <property name="text"> + <string>app</string> + </property> + </item> + <item> + <property name="text"> + <string>lib</string> + </property> + </item> + <property name="name"> + <cstring>comboTemplate</cstring> + </property> + </widget> + </grid> +</widget> +<connections> + <connection language="C++"> + <sender>comboConfig</sender> + <signal>activated(const TQString&)</signal> + <receiver>CppProjectSettings</receiver> + <slot>configPlatformChanged(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>comboLibs</sender> + <signal>activated(const TQString&)</signal> + <receiver>CppProjectSettings</receiver> + <slot>libsPlatformChanged(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>comboDefines</sender> + <signal>activated(const TQString&)</signal> + <receiver>CppProjectSettings</receiver> + <slot>definesPlatformChanged(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>editConfig</sender> + <signal>textChanged(const TQString&)</signal> + <receiver>CppProjectSettings</receiver> + <slot>configChanged(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>editLibs</sender> + <signal>textChanged(const TQString&)</signal> + <receiver>CppProjectSettings</receiver> + <slot>libsChanged(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>editDefines</sender> + <signal>textChanged(const TQString&)</signal> + <receiver>CppProjectSettings</receiver> + <slot>definesChanged(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>editInclude</sender> + <signal>textChanged(const TQString&)</signal> + <receiver>CppProjectSettings</receiver> + <slot>includesChanged(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>comboInclude</sender> + <signal>activated(const TQString&)</signal> + <receiver>CppProjectSettings</receiver> + <slot>includesPlatformChanged(const TQString&)</slot> + </connection> + <slot access="public" specifier="virtual" language="C++" returnType="void">reInit( TQUnknownInterface * iface )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">save( TQUnknownInterface * iface )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">configChanged( const TQString & str )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">libsChanged( const TQString & str )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">definesChanged( const TQString & str )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">includesChanged( const TQString & str )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">configPlatformChanged( const TQString & plat )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">libsPlatformChanged( const TQString & plat )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">definesPlatformChanged( const TQString & plat )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">includesPlatformChanged( const TQString & plat )</slot> +</connections> +<tabstops> + <tabstop>comboTemplate</tabstop> + <tabstop>comboConfig</tabstop> + <tabstop>editConfig</tabstop> + <tabstop>comboLibs</tabstop> + <tabstop>editLibs</tabstop> + <tabstop>comboDefines</tabstop> + <tabstop>editDefines</tabstop> + <tabstop>comboInclude</tabstop> + <tabstop>editInclude</tabstop> +</tabstops> +</UI> diff --git a/tools/designer/plugins/cppeditor/projectsettings.ui.h b/tools/designer/plugins/cppeditor/projectsettings.ui.h new file mode 100644 index 000000000..32e770c93 --- /dev/null +++ b/tools/designer/plugins/cppeditor/projectsettings.ui.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** Add custom slot implementations here. Use a slot init() for +** initialization code called during construction, and a slot destroy() +** for cleanup code called during destruction. +** +** This file gets modified by TQt Designer whenever you add, rename or +** remove custom slots. Implementation code does not get lost. +*****************************************************************************/ + +#include <designerinterface.h> + +void CppProjectSettings::reInit( TQUnknownInterface *iface ) +{ + comboConfig->setCurrentItem( 0 ); + comboLibs->setCurrentItem( 0 ); + comboDefines->setCurrentItem( 0 ); + comboInclude->setCurrentItem( 0 ); + + DesignerInterface *dIface = 0; + iface->queryInterface( IID_Designer, (TQUnknownInterface**)&dIface ); + if ( !dIface ) + return; + DesignerProject *project = dIface->currentProject(); + if ( project->templte() == "app" ) + comboTemplate->setCurrentItem( 0 ); + else + comboTemplate->setCurrentItem( 1 ); + + config.clear(); + defines.clear(); + libs.clear(); + defines.clear(); + includes.clear(); + + const TQString platforms[] = { "(all)", "win32", "unix", "mac", TQString::null }; + for ( int i = 0; platforms[ i ] != TQString::null; ++i ) { + config.replace( platforms[ i ], project->config( platforms[ i ] ) ); + libs.replace( platforms[ i ], project->libs( platforms[ i ] ) ); + defines.replace( platforms[ i ], project->defines( platforms[ i ] ) ); + includes.replace( platforms[ i ], project->includePath( platforms[ i ] ) ); + } + editConfig->setText( config[ "(all)" ] ); + editLibs->setText( libs[ "(all)" ] ); + editDefines->setText( defines[ "(all)" ] ); + editInclude->setText( includes[ "(all)" ] ); +} + +void CppProjectSettings::save( TQUnknownInterface *iface ) +{ + DesignerInterface *dIface = 0; + iface->queryInterface( IID_Designer, (TQUnknownInterface**)&dIface ); + if ( !dIface ) + return; + DesignerProject *project = dIface->currentProject(); + + project->setTemplate( comboTemplate->currentText() ); + const TQString platforms[] = { "(all)", "win32", "unix", "mac", TQString::null }; + for ( int i = 0; platforms[ i ] != TQString::null; ++i ) { + project->setConfig( platforms[ i ], config[ platforms[ i ] ] ); + project->setLibs( platforms[ i ], libs[ platforms[ i ] ] ); + project->setDefines( platforms[ i ], defines[ platforms[ i ] ] ); + project->setIncludePath( platforms[ i ], includes[ platforms[ i ] ] ); + } +} + +void CppProjectSettings::configChanged( const TQString &str ) +{ + config.replace( comboConfig->currentText(), str ); +} + +void CppProjectSettings::libsChanged( const TQString &str ) +{ + libs.replace( comboLibs->currentText(), str ); +} + +void CppProjectSettings::definesChanged( const TQString &str ) +{ + defines.replace( comboDefines->currentText(), str ); +} + +void CppProjectSettings::includesChanged( const TQString &str ) +{ + includes.replace( comboInclude->currentText(), str ); +} + +void CppProjectSettings::configPlatformChanged( const TQString &plat ) +{ + editConfig->setText( config[ plat ] ); +} + +void CppProjectSettings::libsPlatformChanged( const TQString &plat ) +{ + editLibs->setText( libs[ plat ] ); +} + +void CppProjectSettings::definesPlatformChanged( const TQString &plat ) +{ + editDefines->setText( defines[ plat ] ); +} + +void CppProjectSettings::includesPlatformChanged( const TQString &plat ) +{ + editInclude->setText( includes[ plat ] ); +} diff --git a/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.cpp b/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.cpp new file mode 100644 index 000000000..b389b8de9 --- /dev/null +++ b/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.cpp @@ -0,0 +1,106 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "projectsettingsinterfaceimpl.h" +#include "projectsettings.h" + +ProjectSettingsInterfaceImpl::ProjectSettingsInterfaceImpl( TQUnknownInterface *outer ) + : parent( outer ), + ref( 0 ), + settingsTab( 0 ) +{ +} + +ulong ProjectSettingsInterfaceImpl::addRef() +{ + return parent ? parent->addRef() : ref++; +} + +ulong ProjectSettingsInterfaceImpl::release() +{ + if ( parent ) + return parent->release(); + if ( !--ref ) { + delete this; + return 0; + } + return ref; +} + +ProjectSettingsInterface::ProjectSettings *ProjectSettingsInterfaceImpl::projectSetting() +{ + if ( !settingsTab ) { + settingsTab = new CppProjectSettings( 0 ); + settingsTab->hide(); + } + ProjectSettings *pf = 0; + pf = new ProjectSettings; + pf->tab = settingsTab; + pf->title = "C++"; + pf->receiver = pf->tab; + pf->init_slot = SLOT( reInit( TQUnknownInterface * ) ); + pf->accept_slot = SLOT( save( TQUnknownInterface * ) ); + return pf; +} + +TQStringList ProjectSettingsInterfaceImpl::projectSettings() const +{ + return TQStringList(); +} + +void ProjectSettingsInterfaceImpl::connectTo( TQUnknownInterface * ) +{ +} + +void ProjectSettingsInterfaceImpl::deleteProjectSettingsObject( ProjectSettings *pf ) +{ + delete pf; +} + +TQRESULT ProjectSettingsInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) +{ + if ( parent ) + return parent->queryInterface( uuid, iface ); + + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)this; + else if ( uuid == IID_ProjectSettings ) + *iface = (ProjectSettingsInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} diff --git a/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h b/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h new file mode 100644 index 000000000..784b6a022 --- /dev/null +++ b/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h @@ -0,0 +1,62 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef PROJECTSETTINGSINTERFACEIMPL_H +#define PROJECTSETTINGSINTERFACEIMPL_H + +#include <projectsettingsiface.h> + +class CppProjectSettings; + +class ProjectSettingsInterfaceImpl : public ProjectSettingsInterface +{ +public: + ProjectSettingsInterfaceImpl( TQUnknownInterface *outer = 0 ); + + ulong addRef(); + ulong release(); + + ProjectSettings *projectSetting(); + TQStringList projectSettings() const; + void connectTo( TQUnknownInterface *appInterface ); + void deleteProjectSettingsObject( ProjectSettings * ); + TQRESULT queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ); + +private: + TQUnknownInterface *parent; + int ref; + CppProjectSettings *settingsTab; +}; + +#endif diff --git a/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.cpp b/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.cpp new file mode 100644 index 000000000..a9ae3b7ed --- /dev/null +++ b/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.cpp @@ -0,0 +1,117 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "sourcetemplateinterfaceimpl.h" +#include <designerinterface.h> +#include "mainfilesettings.h" +#include <qlineedit.h> +#include <qlistbox.h> + +SourceTemplateInterfaceImpl::SourceTemplateInterfaceImpl() +{ +} + +TQRESULT SourceTemplateInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)this; + else if ( uuid == IID_QFeatureList ) + *iface = (TQFeatureListInterface*)this; + else if ( uuid == IID_SourceTemplate ) + *iface = (SourceTemplateInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +TQStringList SourceTemplateInterfaceImpl::featureList() const +{ + TQStringList l; + l << "C++ Main-File (main.cpp)"; + return l; +} + +static TQString generateMainCppCode( const TQString &formname, const TQString &include ) +{ + TQString code; + code += "#include <qapplication.h>\n"; + code += "#include \"" + include + "\"\n"; + code += "\n"; + code += "int main( int argc, char ** argv )\n"; + code += "{\n"; + code += " TQApplication a( argc, argv );\n"; + code += " " + formname + " w;\n"; + code += " w.show();\n"; + code += " a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( tquit() ) );\n"; + code += " return a.exec();\n"; + code += "}\n"; + return code; +} + +SourceTemplateInterface::Source SourceTemplateInterfaceImpl::create( const TQString &templ, + TQUnknownInterface *appIface ) +{ + SourceTemplateInterface::Source src; + src.type = SourceTemplateInterface::Source::Invalid; + if ( templ == "C++ Main-File (main.cpp)" ) { + CppMainFile dia( 0, 0, TRUE ); + dia.setup( appIface ); + if ( dia.exec() == TQDialog::Accepted ) { + DesignerInterface *dIface = 0; + appIface->queryInterface( IID_Designer, (TQUnknownInterface**)&dIface ); + if ( dIface ) { + src.type = SourceTemplateInterface::Source::FileName; + src.filename = dia.editFileName->text(); + TQString include = dIface->currentProject()-> + formFileName( dia.listForms->text( dia.listForms->currentItem() ) ); + include.remove( include.length() - 2, 2 ); + include += "h"; + int slashFind = include.findRev('/'); + if (slashFind != -1) + include = include.mid(slashFind+1); + src.code = generateMainCppCode( dia.listForms->text( dia.listForms->currentItem() ), + include ); + } + } + } + return src; +} + +TQString SourceTemplateInterfaceImpl::language( const TQString & ) const +{ + return "C++"; +} diff --git a/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h b/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h new file mode 100644 index 000000000..efddc9794 --- /dev/null +++ b/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h @@ -0,0 +1,54 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef SOURCETEMPLATEINTERFACEIMPL_H +#define SOURCETEMPLATEINTERFACEIMPL_H + +#include <sourcetemplateiface.h> + +class SourceTemplateInterfaceImpl : public SourceTemplateInterface +{ +public: + SourceTemplateInterfaceImpl(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** ); + TQStringList featureList() const; + Source create( const TQString &templ, TQUnknownInterface *appIface ); + TQString language( const TQString &templ ) const; + + Q_REFCOUNT +}; + + +#endif diff --git a/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.cpp b/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.cpp new file mode 100644 index 000000000..e1d338430 --- /dev/null +++ b/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.cpp @@ -0,0 +1,550 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "syntaxhighliter_cpp.h" +#include "paragdata.h" +#include "qstring.h" +#include "qstringlist.h" +#include "qmap.h" +#include "qapplication.h" +#include "qregexp.h" + +const char * const SyntaxHighlighter_CPP::keywords[] = { + // C++ keywords + "and", + "and_eq", + "asm", + "auto", + "bitand", + "bitor", + "bool", + "break", + "case", + "catch", + "char", + "class", + "compl", + "const", + "const_cast", + "continue", + "default", + "delete", + "do", + "double", + "dynamic_cast", + "else", + "enum", + "explicit", + "export", + "extern", + "false", + "FALSE", + "float", + "for", + "friend", + "goto", + "if", + "inline", + "int", + "long", + "mutable", + "namespace", + "new", + "not", + "not_eq", + "operator", + "or", + "or_eq", + "private", + "protected", + "public", + "register", + "reinterpret_cast", + "return", + "short", + "signed", + "sizeof", + "static", + "static_cast", + "struct", + "switch", + "template", + "this", + "throw", + "true", + "TRUE", + "try", + "typedef", + "typeid", + "typename", + "union", + "unsigned", + "using", + "virtual", + "void", + "volatile", + "wchar_t", + "while", + "xor", + "xor_eq", + // additional "keywords" intoduced by TQt + "slots", + "signals", + "uint", + "ushort", + "ulong", + "emit", + // end of array + 0 +}; + +static TQMap<int, TQMap<TQString, int > > *wordMap = 0; + +SyntaxHighlighter_CPP::SyntaxHighlighter_CPP() + : TQTextPreProcessor(), lastFormat( 0 ), lastFormatId( -1 ) +{ + TQFont f( qApp->font() ); + + addFormat( Standard, new TQTextFormat( f, TQt::black ) ); + addFormat( Number, new TQTextFormat( f, TQt::darkBlue ) ); + addFormat( String, new TQTextFormat( f, TQt::darkGreen ) ); + addFormat( Type, new TQTextFormat( f, TQt::darkMagenta ) ); + addFormat( Keyword, new TQTextFormat( f, TQt::darkYellow ) ); + addFormat( PreProcessor, new TQTextFormat( f, TQt::darkBlue ) ); + addFormat( Label, new TQTextFormat( f, TQt::darkRed ) ); + f.setFamily( "times" ); + addFormat( Comment, new TQTextFormat( f, TQt::red ) ); + + if ( wordMap ) + return; + + wordMap = new TQMap<int, TQMap<TQString, int> >; + int len; + for ( int i = 0; keywords[ i ]; ++i ) { + len = (int)strlen( keywords[ i ] ); + if ( !wordMap->contains( len ) ) + wordMap->insert( len, TQMap<TQString, int >() ); + TQMap<TQString, int> &map = wordMap->operator[]( len ); + map[ keywords[ i ] ] = Keyword; + } +} + +SyntaxHighlighter_CPP::~SyntaxHighlighter_CPP() +{ +} + +static int string2Id( const TQString &s ) +{ + if ( s == "Standard" ) + return SyntaxHighlighter_CPP::Standard; + if ( s == "Comment" ) + return SyntaxHighlighter_CPP::Comment; + if ( s == "Number" ) + return SyntaxHighlighter_CPP::Number; + if ( s == "String" ) + return SyntaxHighlighter_CPP::String; + if ( s == "Type" ) + return SyntaxHighlighter_CPP::Type; + if ( s == "Preprocessor" ) + return SyntaxHighlighter_CPP::PreProcessor; + if ( s == "Label" ) + return SyntaxHighlighter_CPP::Label; + if ( s == "Keyword" ) + return SyntaxHighlighter_CPP::Keyword; + return SyntaxHighlighter_CPP::Standard; +} + +void SyntaxHighlighter_CPP::updateStyles( const TQMap<TQString, ConfigStyle> &styles ) +{ + for ( TQMap<TQString, ConfigStyle>::ConstIterator it = styles.begin(); it != styles.end(); ++it ) { + int id = string2Id( it.key() ); + TQTextFormat *f = format( id ); + if ( !f ) + continue; + f->setFont( (*it).font ); + f->setColor( (*it).color ); + } +} + +void SyntaxHighlighter_CPP::process( TQTextDocument *doc, TQTextParagraph *string, int, bool invalidate ) +{ + + TQTextFormat *formatStandard = format( Standard ); + TQTextFormat *formatComment = format( Comment ); + TQTextFormat *formatNumber = format( Number ); + TQTextFormat *formatString = format( String ); + TQTextFormat *formatType = format( Type ); + TQTextFormat *formatPreProcessor = format( PreProcessor ); + TQTextFormat *formatLabel = format( Label ); + + // states + const int StateStandard = 0; + const int StateCommentStart1 = 1; + const int StateCCommentStart2 = 2; + const int StateCppCommentStart2 = 3; + const int StateCComment = 4; + const int StateCppComment = 5; + const int StateCCommentEnd1 = 6; + const int StateCCommentEnd2 = 7; + const int StateStringStart = 8; + const int StateString = 9; + const int StateStringEnd = 10; + const int StateString2Start = 11; + const int StateString2 = 12; + const int StateString2End = 13; + const int StateNumber = 14; + const int StatePreProcessor = 15; + + // tokens + const int InputAlpha = 0; + const int InputNumber = 1; + const int InputAsterix = 2; + const int InputSlash = 3; + const int InputParen = 4; + const int InputSpace = 5; + const int InputHash = 6; + const int InputQuotation = 7; + const int InputApostrophe = 8; + const int InputSep = 9; + + static uchar table[ 16 ][ 10 ] = { + { StateStandard, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStandard + { StateStandard, StateNumber, StateCCommentStart2, StateCppCommentStart2, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCommentStart1 + { StateCComment, StateCComment, StateCCommentEnd1, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCCommentStart2 + { StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment }, // CppCommentStart2 + { StateCComment, StateCComment, StateCCommentEnd1, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCComment + { StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment }, // StateCppComment + { StateCComment, StateCComment, StateCCommentEnd1, StateCCommentEnd2, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCCommentEnd1 + { StateStandard, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCCommentEnd2 + { StateString, StateString, StateString, StateString, StateString, StateString, StateString, StateStringEnd, StateString, StateString }, // StateStringStart + { StateString, StateString, StateString, StateString, StateString, StateString, StateString, StateStringEnd, StateString, StateString }, // StateString + { StateStandard, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStringEnd + { StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2End, StateString2 }, // StateString2Start + { StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2End, StateString2 }, // StateString2 + { StateStandard, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateString2End + { StateNumber, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateNumber + { StatePreProcessor, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard } // StatePreProcessor + }; + + TQString buffer; + + int state = StateStandard; + if ( string->prev() ) { + if ( string->prev()->endState() == -1 ) + process( doc, string->prev(), 0, FALSE ); + state = string->prev()->endState(); + } + int input = -1; + int i = 0; + bool lastWasBackSlash = FALSE; + bool makeLastStandard = FALSE; + + ParagData *paragData = (ParagData*)string->extraData(); + if ( paragData ) + paragData->parenList.clear(); + else + paragData = new ParagData; + + TQString alphabeth = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPTQRSTUVWXYZ"; + TQString mathChars = "xXeE"; + TQString numbers = "0123456789"; + bool questionMark = FALSE; + TQChar lastChar; + for (;;) { + TQChar c = string->at( i )->c; + + if ( lastWasBackSlash ) { + input = InputSep; + } else { + switch ( c ) { + case '*': + input = InputAsterix; + break; + case '/': + input = InputSlash; + break; + case '(': case '[': case '{': + input = InputParen; + if ( state == StateStandard || + state == StateNumber || + state == StatePreProcessor || + state == StateCCommentEnd2 || + state == StateCCommentEnd1 || + state == StateString2End || + state == StateStringEnd ) + paragData->parenList << Paren( Paren::Open, c, i ); + break; + case ')': case ']': case '}': + input = InputParen; + if ( state == StateStandard || + state == StateNumber || + state == StatePreProcessor || + state == StateCCommentEnd2 || + state == StateCCommentEnd1 || + state == StateString2End || + state == StateStringEnd ) + paragData->parenList << Paren( Paren::Closed, c, i ); + break; + case '#': + input = InputHash; + break; + case '"': + input = InputQuotation; + break; + case '\'': + input = InputApostrophe; + break; + case ' ': + input = InputSpace; + break; + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': case '0': + if ( alphabeth.find( lastChar ) != -1 && + ( mathChars.find( lastChar ) == -1 || numbers.find( string->at( i - 1 )->c ) == -1 ) ) { + input = InputAlpha; + } else { + if ( input == InputAlpha && numbers.find( lastChar ) != -1 ) + input = InputAlpha; + else + input = InputNumber; + } + break; + case ':': { + input = InputAlpha; + TQChar nextChar = ' '; + if ( i < string->length() - 1 ) + nextChar = string->at( i + 1 )->c; + if ( state == StateStandard && !questionMark && lastChar != ':' && nextChar != ':' ) { + for ( int j = 0; j < i; ++j ) { + if ( string->at( j )->format() == formatStandard ) + string->setFormat( j, 1, formatLabel, FALSE ); + } + } + } break; + default: { + if ( !questionMark && c == '?' ) + questionMark = TRUE; + if ( c.isLetter() || c == '_' ) + input = InputAlpha; + else + input = InputSep; + } break; + } + } + + lastWasBackSlash = !lastWasBackSlash && c == '\\'; + + if ( input == InputAlpha ) + buffer += c; + + state = table[ state ][ input ]; + + switch ( state ) { + case StateStandard: { + int len = buffer.length(); + string->setFormat( i, 1, formatStandard, FALSE ); + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + if ( buffer.length() > 0 && input != InputAlpha ) { + if ( buffer[ 0 ] == 'Q' ) { + string->setFormat( i - buffer.length(), buffer.length(), formatType, FALSE ); + } else { + TQMap<int, TQMap<TQString, int > >::Iterator it = wordMap->find( len ); + if ( it != wordMap->end() ) { + TQMap<TQString, int >::Iterator it2 = ( *it ).find( buffer ); + if ( it2 != ( *it ).end() ) + string->setFormat( i - buffer.length(), buffer.length(), format( ( *it2 ) ), FALSE ); + } + } + buffer = TQString::null; + } + } break; + case StateCommentStart1: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = TRUE; + buffer = TQString::null; + break; + case StateCCommentStart2: + string->setFormat( i - 1, 2, formatComment, FALSE ); + makeLastStandard = FALSE; + buffer = TQString::null; + break; + case StateCppCommentStart2: + string->setFormat( i - 1, 2, formatComment, FALSE ); + makeLastStandard = FALSE; + buffer = TQString::null; + break; + case StateCComment: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatComment, FALSE ); + buffer = TQString::null; + break; + case StateCppComment: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatComment, FALSE ); + buffer = TQString::null; + break; + case StateCCommentEnd1: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatComment, FALSE ); + buffer = TQString::null; + break; + case StateCCommentEnd2: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatComment, FALSE ); + buffer = TQString::null; + break; + case StateStringStart: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatStandard, FALSE ); + buffer = TQString::null; + break; + case StateString: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatString, FALSE ); + buffer = TQString::null; + break; + case StateStringEnd: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatStandard, FALSE ); + buffer = TQString::null; + break; + case StateString2Start: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatStandard, FALSE ); + buffer = TQString::null; + break; + case StateString2: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatString, FALSE ); + buffer = TQString::null; + break; + case StateString2End: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatStandard, FALSE ); + buffer = TQString::null; + break; + case StateNumber: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatNumber, FALSE ); + buffer = TQString::null; + break; + case StatePreProcessor: + if ( makeLastStandard ) + string->setFormat( i - 1, 1, formatStandard, FALSE ); + makeLastStandard = FALSE; + string->setFormat( i, 1, formatPreProcessor, FALSE ); + buffer = TQString::null; + break; + } + + lastChar = c; + i++; + if ( i >= string->length() ) + break; + } + + string->setExtraData( paragData ); + + int oldEndState = string->endState(); + if ( state == StateCComment || + state == StateCCommentEnd1 ) { + string->setEndState( StateCComment ); + } else if ( state == StateString ) { + string->setEndState( StateString ); + } else if ( state == StateString2 ) { + string->setEndState( StateString2 ); + } else { + string->setEndState( StateStandard ); + } + + string->setFirstPreProcess( FALSE ); + + TQTextParagraph *p = string->next(); + if ( (!!oldEndState || !!string->endState()) && oldEndState != string->endState() && + invalidate && p && !p->firstPreProcess() && p->endState() != -1 ) { + while ( p ) { + if ( p->endState() == -1 ) + return; + p->setEndState( -1 ); + p = p->next(); + } + } +} + +TQTextFormat *SyntaxHighlighter_CPP::format( int id ) +{ + if ( lastFormatId == id && lastFormat ) + return lastFormat; + + TQTextFormat *f = formats[ id ]; + lastFormat = f ? f : formats[ 0 ]; + lastFormatId = id; + return lastFormat; +} + +void SyntaxHighlighter_CPP::addFormat( int id, TQTextFormat *f ) +{ + formats.insert( id, f ); +} + +void SyntaxHighlighter_CPP::removeFormat( int id ) +{ + formats.remove( id ); +} + diff --git a/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.h b/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.h new file mode 100644 index 000000000..25b16607f --- /dev/null +++ b/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.h @@ -0,0 +1,73 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCPPSYNTAXHIGHLIGHTER_H +#define TQCPPSYNTAXHIGHLIGHTER_H + +#include <private/qrichtext_p.h> +#include <conf.h> + +class SyntaxHighlighter_CPP : public TQTextPreProcessor +{ +public: + enum CppIds { + Comment = 1, + Number, + String, + Type, + Keyword, + PreProcessor, + Label + }; + + SyntaxHighlighter_CPP(); + virtual ~SyntaxHighlighter_CPP(); + void process( TQTextDocument *doc, TQTextParagraph *string, int start, bool invalidate = TRUE ); + void updateStyles( const TQMap<TQString, ConfigStyle> &styles ); + + static const char * const keywords[]; + + TQTextFormat *format( int id ); + +private: + void addFormat( int id, TQTextFormat *f ); + void removeFormat( int id ); + + TQTextFormat *lastFormat; + int lastFormatId; + TQIntDict<TQTextFormat> formats; + +}; + +#endif diff --git a/tools/designer/plugins/cppeditor/yyreg.cpp b/tools/designer/plugins/cppeditor/yyreg.cpp new file mode 100644 index 000000000..2e0709e46 --- /dev/null +++ b/tools/designer/plugins/cppeditor/yyreg.cpp @@ -0,0 +1,800 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include <qregexp.h> + +#include <ctype.h> +#include <stdio.h> + +#include "yyreg.h" + +/* + First comes the tokenizer. We don't need something that knows much + about C++. However, we need something that gives tokens from the + end of the file to the start, which is tricky. + + If you are not familiar with hand-written tokenizers and parsers, + you might want to read other simpler parsers written in the same + style: + + $(QTDIR)/src/tools/qregexp.cpp + $(QTDIR)/tools/inspector/cppparser.cpp + + You might also want to read Section 2 in the Dragon Book. +*/ + +/* + Those are the tokens we are interested in. Tok_Something represents + any C++ token that does not interest us, but it's dangerous to + ignore tokens completely. +*/ +enum { Tok_Boi, Tok_Ampersand, Tok_Aster, Tok_LeftParen, Tok_RightParen, + Tok_Equal, Tok_LeftBrace, Tok_RightBrace, Tok_Semicolon, Tok_Colon, + Tok_LeftAngle, Tok_RightAngle, Tok_Comma, Tok_Ellipsis, Tok_Gulbrandsen, + Tok_LeftBracket, Tok_RightBracket, Tok_Tilde, Tok_Something, Tok_Comment, + Tok_Ident, + + Tok_char, Tok_const, Tok_double, Tok_int, Tok_long, Tok_operator, + Tok_short, Tok_signed, Tok_unsigned }; + +/* + The following variables store the lexical analyzer state. The best way + to understand them is to implement a function myGetToken() that calls + getToken(), to add some qDebug() statements in there and then to + #define getToken() myGetToken(). +*/ +static TQString *yyIn; // the input stream +static int yyPos; // the position of the current token in yyIn +static int yyCurPos; // the position of the next lookahead character +static char *yyLexBuf; // the lexeme buffer +static const int YYLexBufSize = 65536; // big enough for long comments +static char *yyLex; // the lexeme itself (a pointer into yyLexBuf) +static int yyCh; // the lookbehind character + +/* + Moves back to the previous character in the input stream and + updates the tokenizer state. This function is to be used only by + getToken(), which provides the right abstraction. +*/ +static inline void readChar() +{ + if ( yyCh == EOF ) + return; + + if ( yyLex > yyLexBuf ) + *--yyLex = (char) yyCh; + + if ( yyCurPos < 0 ) + yyCh = EOF; + else + yyCh = (*yyIn)[yyCurPos].unicode(); + yyCurPos--; +} + +/* + Sets up the tokenizer. +*/ +static void startTokenizer( const TQString& in ) +{ + yyIn = new TQString; + *yyIn = in; + yyPos = yyIn->length() - 1; + yyCurPos = yyPos; + yyLexBuf = new char[YYLexBufSize]; + yyLex = yyLexBuf + YYLexBufSize - 1; + *yyLex = '\0'; + yyCh = '\0'; + readChar(); +} + +/* + Frees resources allocated by the tokenizer. +*/ +static void stopTokenizer() +{ + delete yyIn; + delete[] yyLexBuf; + yyLexBuf = 0; +} + +/* + These two macros implement tquick-and-dirty hashing for telling + apart keywords fast. +*/ +#define HASH( ch, len ) ( (ch) | ((len) << 8) ) +#define CHECK( target ) \ + if ( strcmp((target), yyLex) != 0 ) \ + break; + +/* + Returns the previous token in the abstract token stream. The parser + deals only with tokens, not with characters. +*/ +static int getToken() +{ + // why "+ 2"? try putting some qDebug()'s and see + yyPos = yyCurPos + 2; + + for ( ;; ) { + /* + See if the previous token is interesting. If it isn't, we + will loop anyway an go to the token before the previous + token, and so on. + */ + + yyLex = yyLexBuf + YYLexBufSize - 1; + *yyLex = '\0'; + + if ( yyCh == EOF ) { + break; + } else if ( isspace(yyCh) ) { + bool metNL = FALSE; + do { + metNL = ( metNL || yyCh == '\n' ); + readChar(); + } while ( isspace(yyCh) ); + + if ( metNL ) { + /* + C++ style comments are tricky. In left-to-right + thinking, C++ comments start with "//" and end with + '\n'. In right-to-left thinking, they start with a + '\n'; but of course not every '\n' starts a comment. + + When we meet the '\n', we look behind, on the same + line, for a "//", and if there is one we mess + around with the tokenizer state to effectively + ignore the comment. Beware of off-by-one and + off-by-two bugs when you modify this code by adding + qDebug()'s here and there. + */ + if ( yyCurPos >= 0 ) { + int lineStart = yyIn->findRev( TQChar('\n'), yyCurPos ) + 1; + TQString line = yyIn->mid( lineStart, + yyCurPos - lineStart + 2 ); + int commentStart = line.find( TQString("//") ); + if ( commentStart != -1 ) { + yyCurPos = lineStart + commentStart - 1; + yyPos = yyCurPos + 2; + readChar(); + } + } + } + } else if ( isalnum(yyCh) || yyCh == '_' ) { + do { + readChar(); + } while ( isalnum(yyCh) || yyCh == '_' ); + + switch ( HASH(yyLex[0], strlen(yyLex)) ) { + case HASH( 'c', 4 ): + CHECK( "char" ); + return Tok_char; + case HASH( 'c', 5 ): + CHECK( "const" ); + return Tok_const; + case HASH( 'd', 6 ): + CHECK( "double" ); + return Tok_double; + case HASH( 'i', 3 ): + CHECK( "int" ); + return Tok_int; + case HASH( 'l', 4 ): + CHECK( "long" ); + return Tok_long; + case HASH( 'o', 8 ): + CHECK( "operator" ); + return Tok_operator; + case HASH( 's', 5 ): + CHECK( "short" ); + return Tok_short; + case HASH( 's', 6 ): + CHECK( "signed" ); + return Tok_signed; + case HASH( 'u', 8 ): + CHECK( "unsigned" ); + return Tok_unsigned; + } + if ( isdigit(*yyLex) ) + return Tok_Something; + else + return Tok_Ident; + } else { + int quote; + + switch ( yyCh ) { + case '!': + case '%': + case '^': + case '+': + case '-': + case '?': + case '|': + readChar(); + return Tok_Something; + case '"': + case '\'': + quote = yyCh; + readChar(); + + while ( yyCh != EOF && yyCh != '\n' ) { + if ( yyCh == quote ) { + readChar(); + if ( yyCh != '\\' ) + break; + } else { + readChar(); + } + } + return Tok_Something; + case '&': + readChar(); + if ( yyCh == '&' ) { + readChar(); + return Tok_Something; + } else { + return Tok_Ampersand; + } + case '(': + readChar(); + return Tok_LeftParen; + case ')': + readChar(); + return Tok_RightParen; + case '*': + readChar(); + return Tok_Aster; + case ',': + readChar(); + return Tok_Comma; + case '.': + readChar(); + if ( yyCh == '.' ) { + do { + readChar(); + } while ( yyCh == '.' ); + return Tok_Ellipsis; + } else { + return Tok_Something; + } + case '/': + /* + C-style comments are symmetric. C++-style comments + are handled elsewhere. + */ + readChar(); + if ( yyCh == '*' ) { + bool metAster = FALSE; + bool metAsterSlash = FALSE; + + readChar(); + + while ( !metAsterSlash ) { + if ( yyCh == EOF ) + break; + + if ( yyCh == '*' ) + metAster = TRUE; + else if ( metAster && yyCh == '/' ) + metAsterSlash = TRUE; + else + metAster = FALSE; + readChar(); + } + break; + // return Tok_Comment; + } else { + return Tok_Something; + } + case ':': + readChar(); + if ( yyCh == ':' ) { + readChar(); + return Tok_Gulbrandsen; + } else { + return Tok_Colon; + } + case ';': + readChar(); + return Tok_Semicolon; + case '<': + readChar(); + return Tok_LeftAngle; + case '=': + readChar(); + return Tok_Equal; + case '>': + readChar(); + return Tok_RightAngle; + case '[': + readChar(); + return Tok_LeftBracket; + case ']': + readChar(); + return Tok_RightBracket; + case '{': + readChar(); + return Tok_LeftBrace; + case '}': + readChar(); + return Tok_RightBrace; + case '~': + readChar(); + return Tok_Tilde; + default: + readChar(); + } + } + } + return Tok_Boi; +} + +/* + Follow the member function(s) of CppFunction. +*/ + +/* + Returns the prototype for the C++ function, without the semicolon. +*/ +TQString CppFunction::prototype() const +{ + TQString proto; + + if ( !returnType().isEmpty() ) + proto = returnType() + TQChar( ' ' ); + proto += scopedName(); + proto += TQChar( '(' ); + if ( !parameterList().isEmpty() ) { + TQStringList::ConstIterator p = parameterList().begin(); + proto += *p; + ++p; + while ( p != parameterList().end() ) { + proto += TQString( ", " ); + proto += *p; + ++p; + } + } + proto += TQChar( ')' ); + if ( isConst() ) + proto += TQString( " const" ); + return proto; +} + +/* + The parser follows. We are not really parsing C++, just trying to + find the start and end of function definitions. + + One important pitfall is that the parsed code needs not be valid. + Parsing from right to left helps cope with that, as explained in + comments below. + + In the examples, we will use the symbol @ to stand for the position + in the token stream. In "int @ x ;", the lookahead token (yyTok) is + 'int'. +*/ + +static int yyTok; // the current token + +/* + Returns TRUE if thingy is a constructor or a destructor; otherwise + returns FALSE. +*/ +static bool isCtorOrDtor( const TQString& thingy ) +{ + // e.g., Alpha<a>::Beta<Bar<b, c> >::~Beta + TQRegExp xtor( TQString( + "(?:([A-Z_a-z][0-9A-Z_a-z]*)" // class name + "(?:<(?:[^>]|<[^>]*>)*>)*" // template arguments + "::)+" // many in a row + "~?" // ctor or dtor? + "\\1") ); // function has same name as class + return xtor.exactMatch( thingy ); +} + +/* + Skips over any template arguments with balanced angle brackets, and + returns the skipped material as a string. + + Before: TQMap < TQString , TQValueList < TQString > > @ m ; + After: TQMap @ < TQString , TQValueList < TQString > > m ; +*/ +static TQString matchTemplateAngles() +{ + TQString t; + + if ( yyTok == Tok_RightAngle ) { + int depth = 0; + do { + if ( yyTok == Tok_RightAngle ) + depth++; + else if ( yyTok == Tok_LeftAngle ) + depth--; + t.prepend( yyLex ); + yyTok = getToken(); + } while ( depth > 0 && yyTok != Tok_Boi && yyTok != Tok_LeftBrace ); + } + return t; +} + +/* + Similar to matchTemplateAngles(), but for array brackets in parameter + data types (as in "int *argv[]"). +*/ +static TQString matchArrayBrackets() +{ + TQString t; + + while ( yyTok == Tok_RightBracket ) { + t.prepend( yyLex ); + yyTok = getToken(); + if ( yyTok == Tok_Something ) { + t.prepend( yyLex ); + yyTok = getToken(); + } + if ( yyTok != Tok_LeftBracket ) + return TQString::null; + t.prepend( yyLex ); + yyTok = getToken(); + } + return t; +} + +/* + Prepends prefix to *type. This operation is in theory trivial, but + for the spacing to look good, we have to do something. The original + spacing is lost as the input is tokenized. +*/ +static void prependToType( TQString *type, const TQString& prefix ) +{ + if ( !type->isEmpty() && !prefix.isEmpty() ) { + TQChar left = prefix[(int) prefix.length() - 1]; + TQChar right = (*type)[0]; + + if ( left.isLetter() && + (right.isLetter() || right == TQChar('*') || right == TQChar('&')) ) + type->prepend( TQChar(' ') ); + } + type->prepend( prefix ); +} + +static bool isModifier( int tok ) +{ + return ( tok == Tok_signed || tok == Tok_unsigned || + tok == Tok_short || tok == Tok_long ); +} + +/* + Parses a data type (backwards as usual) and returns a textual + representation of it. +*/ +static TQString matchDataType() +{ + TQString type; + + while ( yyTok == Tok_Ampersand || yyTok == Tok_Aster || + yyTok == Tok_const ) { + prependToType( &type, yyLex ); + yyTok = getToken(); + } + + /* + This code is really hard to follow... sorry. The loop matches + Alpha::Beta::Gamma::...::Omega. + */ + for ( ;; ) { + bool modifierMet = FALSE; + + prependToType( &type, matchTemplateAngles() ); + + if ( yyTok != Tok_Ident ) { + /* + People may write 'const unsigned short' or + 'short unsigned const' or any other permutation. + */ + while ( yyTok == Tok_const || isModifier(yyTok) ) { + prependToType( &type, yyLex ); + yyTok = getToken(); + if ( yyTok != Tok_const ) + modifierMet = TRUE; + } + + if ( yyTok == Tok_Tilde ) { + prependToType( &type, yyLex ); + yyTok = getToken(); + } + } + + if ( !modifierMet ) { + if ( yyTok == Tok_Ellipsis || yyTok == Tok_Ident || + yyTok == Tok_char || yyTok == Tok_int || + yyTok == Tok_double ) { + prependToType( &type, yyLex ); + yyTok = getToken(); + } else { + return TQString::null; + } + } else if ( yyTok == Tok_int || yyTok == Tok_char || + yyTok == Tok_double ) { + prependToType( &type, yyLex ); + yyTok = getToken(); + } + + while ( yyTok == Tok_const || isModifier(yyTok) ) { + prependToType( &type, yyLex ); + yyTok = getToken(); + } + + if ( yyTok == Tok_Gulbrandsen ) { + prependToType( &type, yyLex ); + yyTok = getToken(); + } else { + break; + } + } + return type; +} + +/* + Parses a function prototype (without the semicolon) and returns an + object that stores information about this function. +*/ +static CppFunction matchFunctionPrototype( bool stripParamNames ) +{ + CppFunction func; +#if 0 + TQString documentation; +#endif + TQString returnType; + TQString scopedName; + TQStringList params; + TQString qualifier; + bool cnst = FALSE; + + if ( yyTok == Tok_const ) { + cnst = TRUE; + yyTok = getToken(); + } + + if ( yyTok != Tok_RightParen ) + return func; + yyTok = getToken(); + + if ( yyTok != Tok_LeftParen ) { + for ( ;; ) { + TQString brackets = matchArrayBrackets(); + TQString name; + if ( yyTok == Tok_Ident ) { + name = yyLex; + yyTok = getToken(); + } + TQString type = matchDataType(); + + if ( type.isEmpty() ) { + if ( name.isEmpty() ) + return func; + type = name; + name = TQString::null; + } + if ( stripParamNames ) + name = TQString::null; + + TQString param = type + TQChar( ' ' ) + name + brackets; + params.prepend( param.stripWhiteSpace() ); + + if ( yyTok != Tok_Comma ) + break; + yyTok = getToken(); + } + if ( yyTok != Tok_LeftParen ) + return func; + } + yyTok = getToken(); + + for ( ;; ) { + scopedName.prepend( matchTemplateAngles() ); + + if ( yyTok != Tok_Ident ) { + // the operator keyword should be close + int i = 0; + while ( i < 4 && yyTok != Tok_operator ) { + scopedName.prepend( yyLex ); + i++; + } + if ( yyTok != Tok_operator ) + return func; + } + scopedName.prepend( yyLex ); + yyTok = getToken(); + + if ( yyTok != Tok_Gulbrandsen ) + break; + scopedName.prepend( yyLex ); + yyTok = getToken(); + } + + if ( !isCtorOrDtor(scopedName) ) { + returnType = matchDataType(); + if ( returnType.isEmpty() ) + return func; + } + + /* + The documentation feature is unused so far, since we cannot + really distinguist between a normal comment between two + functions and one that relates to the following function. One + good heuristic is to assume that a comment immediately followed + by a function with no blank line in between relates to the + function, but there's no easy way to find that out with a + tokenizer. + */ +#if 0 + if ( yyTok == Tok_Comment ) { + documentation = yyLex; + yyTok = getToken(); + } + + func.setDocumentation( documentation ); +#endif + func.setReturnType( returnType ); + func.setScopedName( scopedName ); + func.setParameterList( params ); + func.setConst( cnst ); + return func; +} + +/* + Try to set the body. It's not sufficient to call + func->setBody(somewhatBody), as the somewhatBody might be too large. + Case in point: + + void foo() + { + printf( "Hello" ); + } + + int n; + + void bar() + { + printf( " world!\n" ); + } + + The parser first finds bar(). Then it finds "void foo() {" and + naively expects the body to extend up to "void bar()". This + function's job is to count braces and make sure "int n;" is not + counted as part of the body. + + Cases where the closing brace of the body is missing retquire no + special processing. +*/ +static void setBody( CppFunction *func, const TQString& somewhatBody ) +{ + TQString body = somewhatBody; + + int braceDepth = 0; + int i = 0; + while ( i < (int) body.length() ) { + if ( body[i] == TQChar('{') ) { + braceDepth++; + } else if ( body[i] == TQChar('}') ) { + braceDepth--; + if ( braceDepth == 0 ) { + body.truncate( i + 1 ); + break; + } + } + i++; + } + + func->setBody( body ); +} + +/* + Parses a whole C++ file, looking for function definitions. Case in + point: + + void foo() + { + printf( "Hello" ); + + void bar() + { + printf( " world!\n" ); + } + + The parser looks for left braces and tries to parse a function + prototype backwards. First it finds "void bar() {". Then it works + up and finds "void foo() {". +*/ +static void matchTranslationUnit( TQValueList<CppFunction> *flist ) +{ + int endBody = -1; + int startBody; + + for ( ;; ) { + if ( endBody == -1 ) + endBody = yyPos; + + while ( yyTok != Tok_Boi && yyTok != Tok_LeftBrace ) + yyTok = getToken(); + if ( yyTok == Tok_Boi ) + break; + + // found a left brace + yyTok = getToken(); + startBody = yyPos; + CppFunction func = matchFunctionPrototype( FALSE ); + if ( !func.scopedName().isEmpty() ) { + TQString body = yyIn->mid( startBody, endBody - startBody ); + setBody( &func, body ); + body = func.body(); // setBody() can change the body + + /* + Compute important line numbers. + */ + int functionStartLineNo = 1 + TQConstString( yyIn->unicode(), yyPos ) + .string().contains( TQChar('\n') ); + int startLineNo = functionStartLineNo + + TQConstString( yyIn->unicode() + yyPos, startBody - yyPos ) + .string().contains( TQChar('\n') ); + int endLineNo = startLineNo + body.contains( TQChar('\n') ); + + func.setLineNums( functionStartLineNo, startLineNo, endLineNo ); + flist->prepend( func ); + endBody = -1; + } + } +} + +/* + Extracts C++ function from source code and put them in a list. +*/ +void extractCppFunctions( const TQString& code, TQValueList<CppFunction> *flist ) +{ + startTokenizer( code ); + yyTok = getToken(); + matchTranslationUnit( flist ); + stopTokenizer(); +} + +/* + Returns the prototype with the parameter names removed. +*/ +TQString canonicalCppProto( const TQString& proto ) +{ + startTokenizer( proto ); + yyTok = getToken(); + CppFunction func = matchFunctionPrototype( TRUE ); + stopTokenizer(); + return func.prototype(); +} diff --git a/tools/designer/plugins/cppeditor/yyreg.h b/tools/designer/plugins/cppeditor/yyreg.h new file mode 100644 index 000000000..42a352e03 --- /dev/null +++ b/tools/designer/plugins/cppeditor/yyreg.h @@ -0,0 +1,88 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef YYREG_H +#define YYREG_H + +#include <qstringlist.h> +#include <qvaluelist.h> + +class CppFunction +{ +public: + CppFunction() : cnst( FALSE ), lineno1( 0 ), lineno2( 0 ) { } + + void setReturnType( const TQString& r ) { ret = r; } + void setScopedName( const TQString& n ) { nam = n; } + void setParameterList( const TQStringList& p ) { params = p; } + void setConst( bool c ) { cnst = c; } + void setBody( const TQString& b ) { bod = b; } + void setDocumentation( const TQString& d ) { doc = d; } + void setLineNums( int functionStart, int openingBrace, int closingBrace ) { + lineno0 = functionStart; + lineno1 = openingBrace; + lineno2 = closingBrace; + } + + const TQString& returnType() const { return ret; } + const TQString& scopedName() const { return nam; } + const TQStringList& parameterList() const { return params; } + bool isConst() const { return cnst; } + TQString prototype() const; + const TQString& body() const { return bod; } + const TQString& documentation() const { return doc; } + int functionStartLineNum() const { return lineno0; } + int openingBraceLineNum() const { return lineno1; } + int closingBraceLineNum() const { return lineno2; } + +#if defined(Q_FULL_TEMPLATE_INSTANTIATION) + bool operator==( const CppFunction& ) const { return FALSE; } +#endif + +private: + TQString ret; + TQString nam; + TQStringList params; + bool cnst; + TQString bod; + TQString doc; + int lineno0; + int lineno1; + int lineno2; +}; + +void extractCppFunctions( const TQString& code, TQValueList<CppFunction> *flist ); +TQString canonicalCppProto( const TQString& proto ); + +#endif diff --git a/tools/designer/plugins/dlg/dlg.pro b/tools/designer/plugins/dlg/dlg.pro new file mode 100644 index 000000000..ee93cb912 --- /dev/null +++ b/tools/designer/plugins/dlg/dlg.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +CONFIG += qt warn_on release plugin +HEADERS = dlg2ui.h +SOURCES = main.cpp dlg2ui.cpp +DESTDIR = ../../../../plugins/designer +DEFINES += QT_INTERNAL_XML +include( ../../../../src/qt_professional.pri ) +TARGET = dlgplugin +INCLUDEPATH += ../../interfaces + + +target.path += $$plugins.path/designer +INSTALLS += target diff --git a/tools/designer/plugins/dlg/dlg2ui.cpp b/tools/designer/plugins/dlg/dlg2ui.cpp new file mode 100644 index 000000000..be123b566 --- /dev/null +++ b/tools/designer/plugins/dlg/dlg2ui.cpp @@ -0,0 +1,1632 @@ +/********************************************************************** +** +** Converts a TQt Architect 2.1+ .dlg file into a .ui file. +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "dlg2ui.h" +#include <qfile.h> +#include <qframe.h> +#include <qmessagebox.h> +#include <qregexp.h> +#include <qtextstream.h> + +/* + Possible improvements: + + 1. Convert layout stretch factors to size policy stretches, now + that TQt Designer supports the latter. +*/ + +/* + These big tables could be more or less eliminated by using TQt's + TQMetaObject and TQMetaProperty classes. However, the interface of + these classes is unwieldy for an otherwise non-GUI program like this + one, as we would have to create one dummy object for most TQObject + subclasses in TQt. Let's take the safe road. +*/ + +static const char *widgetTypes[] = { + "Button", "ButtonGroup", "CheckBox", "ComboBox", "Dial", "DlgWidget", + "Frame", "Grid", "GroupBox", "HBox", "HButtonGroup", "HGroupBox", + "IconView", "LCDNumber", "Label", "LineEdit", "ListBox", "ListView", + "MenuBar", "MultiLineEdit", "ProgressBar", "PushButton", "RadioButton", + "ScrollBar", "ScrollView", "Slider", "SpinBox", "Splitter", "TabBar", + "TextBrowser", "TextView", "User", "VBox", "VButtonGroup", "VGroupBox", 0 +}; + +/* + This table maps TQt Architect properties to TQt Designer properties. + If there is no corresponding TQt Designer property, qtName is 0 and + the property can be handled explicitly. +*/ +static const struct { + const char *widgetName; + const char *architectName; + const char *qtName; + const char *type; +} propertyDefs[] = { + { "Button", "AutoRepeat", "autoRepeat", "boolean" }, + { "Button", "AutoResize", 0, 0 }, + { "Button", "Text", "text", "qstring" }, + { "ButtonGroup", "Exclusive", "exclusive", "boolean" }, + { "ButtonGroup", "RadioButtonExclusive", "radioButtonExclusive", + "boolean" }, + { "CheckBox", "Checked", "checked", "boolean" }, + { "ComboBox", "AutoCompletion", "autoCompletion", "boolean" }, + { "ComboBox", "AutoResize", 0, 0 }, + { "ComboBox", "DuplicatesEnabled", "duplicatesEnabled", "boolean" }, + { "ComboBox", "MaxCount", "maxCount", "integer" }, + { "ComboBox", "Policy", "insertionPolicy", "enum" }, + { "ComboBox", "SizeLimit", "sizeLimit", "integer" }, + { "ComboBox", "Style", 0, 0 }, + { "Dial", "Initial", "value", "integer" }, + { "Dial", "LineStep", "lineStep", "integer" }, + { "Dial", "MaxValue", "maxValue", "integer" }, + { "Dial", "MinValue", "minValue", "integer" }, + { "Dial", "NotchTarget", "notchTarget", "double" }, + { "Dial", "PageStep", "pageStep", "integer" }, + { "Dial", "ShowNotches", "notchesVisible", "boolean" }, + { "Dial", "Tracking", "tracking", "boolean" }, + { "Dial", "Wrapping", "wrapping", "boolean" }, + { "DlgWidget", "AdjustSize", 0, 0 }, + { "DlgWidget", "BackgroundMode", "backgroundMode", "enum" }, + { "DlgWidget", "BackgroundOrigin", "backgroundOrigin", "enum" }, + { "DlgWidget", "BackgroundPixmap", "backgroundPixmap", "qpixmap" }, + { "DlgWidget", "DataLenName", 0, 0 }, + { "DlgWidget", "DataVarName", 0, 0 }, + { "DlgWidget", "Enabled", "enabled", "boolean" }, + { "DlgWidget", "FocusPolicy", "focusPolicy", "enum" }, + { "DlgWidget", "Font", "font", "qfont" }, + { "DlgWidget", "FontPropagation", 0, 0 }, + { "DlgWidget", "MaximumSize", "maximumSize", "qsize" }, + { "DlgWidget", "MinimumSize", "minimumSize", "qsize" }, + { "DlgWidget", "Name", 0, 0 }, + { "DlgWidget", "Palette", "palette", "qpalette" }, + { "DlgWidget", "PalettePropagation", 0, 0 }, + { "DlgWidget", "ReadPixmapFromData", 0, 0 }, + { "DlgWidget", "Rect", 0, 0 }, + { "DlgWidget", "SignalConnection", 0, 0 }, + { "DlgWidget", "UseBackgroudPixmap", 0, 0 }, + { "DlgWidget", "Variable", 0, 0 }, + { "Frame", "FrameMargin", "margin", "integer" }, + { "Frame", "LineWidth", "lineWidth", "integer" }, + { "Frame", "MidLineWidth", "midLineWidth", "integer" }, + { "Frame", "Style", 0, 0 }, + { "GroupBox", "Title", "title", "qstring" }, + { "IconView", "AlignMode", 0, 0 }, + { "IconView", "Aligning", 0, 0 }, + { "IconView", "Arrangement", "arrangement", "enum" }, + { "IconView", "AutoArrange", "autoArrange", "boolean" }, + { "IconView", "EnableMoveItems", "itemsMovable", "boolean" }, + { "IconView", "GridX", "gridX", "integer" }, + { "IconView", "GridY", "gridY", "integer" }, + { "IconView", "ItemTextPos", "itemTextPos", "enum" }, + { "IconView", "ItemsMovable", "itemsMovable", "boolean" }, + { "IconView", "MaxItemTextLength", "maxItemTextLength", "integer" }, + { "IconView", "MaxItemWidth", "maxItemWidth", "integer" }, + { "IconView", "ResizeMode", "resizeMode", "enum" }, + { "IconView", "SelectionMode", "selectionMode", "enum" }, + { "IconView", "ShowToolTips", "showToolTips", "boolean" }, + { "IconView", "SortAscending", "sortDirection", "bool" }, + { "IconView", "Spacing", "spacing", "integer" }, + { "IconView", "WordWrapIconText", "wordWrapIconText", "boolean" }, + { "LCDNumber", "Digits", "numDigits", "integer" }, + { "LCDNumber", "Mode", "mode", "enum" }, + { "LCDNumber", "SegmentStyle", "segmentStyle", "enum" }, + { "LCDNumber", "SmallDecimalPoint", "smallDecimalPoint", "boolean" }, + { "LCDNumber", "Value", 0, 0 }, + { "Label", "AutoResize", 0, 0 }, + { "Label", "Indent", "indent", "integer" }, + { "Label", "Text", "text", "qstring" }, + { "Label", "TextFormat", "textFormat", "enum" }, + { "LineEdit", "EchoMode", "echoMode", "enum" }, + { "LineEdit", "FrameShown", "frame", "boolean" }, + { "LineEdit", "MaxLength", "maxLength", "integer" }, + { "LineEdit", "Text", "text", "qstring" }, + { "ListBox", "AutoScroll", 0, 0 }, + { "ListBox", "AutoUpdate", 0, 0 }, + { "ListBox", "ColumnMode", "columnMode", "enum" }, + { "ListBox", "DragSelect", 0, 0 }, + { "ListBox", "RowMode", "rowMode", "enum" }, + { "ListBox", "SelectionMode", "selectionMode", "enum" }, + { "ListBox", "SmoothScrolling", 0, 0 }, + { "ListView", "AllColumnsShowFocus", "allColumnsShowFocus", "boolean" }, + { "ListView", "HeaderInformation", 0, 0 }, + { "ListView", "ItemMargin", "itemMargin", "integer" }, + { "ListView", "MultiSelection", "multiSelection", "boolean" }, + { "ListView", "RootIsDecorated", "rootIsDecorated", "boolean" }, + { "ListView", "TreeStepSize", "treeStepSize", "boolean" }, + { "MultiLineEdit", "AutoUpdate", 0, 0 }, + { "MultiLineEdit", "EchoMode", 0, 0 }, + { "MultiLineEdit", "HorizontalMargin", 0, 0 }, + { "MultiLineEdit", "MaxLength", 0, 0 }, + { "MultiLineEdit", "MaxLineLength", 0, 0 }, + { "MultiLineEdit", "MaxLines", 0, 0 }, + { "MultiLineEdit", "OverwriteMode", 0, 0 }, + { "MultiLineEdit", "ReadOnly", 0, 0 }, + { "MultiLineEdit", "Text", 0, 0 }, + { "MultiLineEdit", "UndoDepth", "undoDepth", "integer" }, + { "MultiLineEdit", "UndoEnabled", 0, 0 }, + { "MultiLineEdit", "WordWrap", 0, 0 }, + { "MultiLineEdit", "WrapColumnOrWidth", 0, 0 }, + { "MultiLineEdit", "WrapPolicy", 0, 0 }, + { "ProgressBar", "CenterIndicator", "centerIndicator", "boolean" }, + { "ProgressBar", "IndicatorFollowsStyle", "indicatorFollowsStyle", + "boolean" }, + { "ProgressBar", "Progress", "progress", "integer" }, + { "ProgressBar", "TotalSteps", "totalSteps", "integer" }, + { "PushButton", "AutoDefault", "autoDefault", "boolean" }, + { "PushButton", "Default", "default", "boolean" }, + { "PushButton", "IsMenuButton", 0, 0 }, + { "PushButton", "ToggleButton", "toggleButton", "boolean" }, + { "RadioButton", "Checked", "checked", "boolean" }, + { "ScrollBar", "Initial", "value", "integer" }, + { "ScrollBar", "LineStep", "lineStep", "integer" }, + { "ScrollBar", "MaxValue", "maxValue", "integer" }, + { "ScrollBar", "MinValue", "minValue", "integer" }, + { "ScrollBar", "Orientation", "orientation", "enum" }, + { "ScrollBar", "PageStep", "pageStep", "integer" }, + { "ScrollBar", "Tracking", "tracking", "boolean" }, + { "ScrollView", "DragAutoScroll", "dragAutoScroll", "boolean" }, + { "ScrollView", "HScrollBarMode", "hScrollBarMode", "enum" }, + { "ScrollView", "ResizePolicy", "resizePolicy", "enum" }, + { "ScrollView", "VScrollBarMode", "vScrollBarMode", "enum" }, + { "Slider", "Initial", "value", "integer" }, + { "Slider", "LineStep", "lineStep", "integer" }, + { "Slider", "MaxValue", "maxValue", "integer" }, + { "Slider", "MinValue", "minValue", "integer" }, + { "Slider", "Orientation", "orientation", "enum" }, + { "Slider", "PageStep", "pageStep", "integer" }, + { "Slider", "TickInterval", "tickInterval", "integer" }, + { "Slider", "Tickmarks", "tickmarks", "enum" }, + { "Slider", "Tracking", "tracking", "boolean" }, + { "SpinBox", "ButtonSymbols", "buttonSymbols", "enum" }, + { "SpinBox", "MaxValue", "maxValue", "integer" }, + { "SpinBox", "MinValue", "minValue", "integer" }, + { "SpinBox", "Prefix", "prefix", "qstring" }, + { "SpinBox", "SpecialValue", "specialValueText", "qstring" }, + { "SpinBox", "Step", "lineStep", "integer" }, + { "SpinBox", "Suffix", "suffix", "qstring" }, + { "SpinBox", "Wrapping", "wrapping", "boolean" }, + { "Splitter", "OpaqueResize", 0, 0 }, + { "Splitter", "Orientation", "orientation", "enum" }, + { "TabBar", "Shape", "shape", "enum" }, + { "TabBar", "TabNames", 0, 0 }, + { "TextView", "Context", 0, 0 }, + { "TextView", "LinkUnderline", "linkUnderline", "boolean" }, + { "TextView", "Text", "text", "qstring" }, + { "TextView", "TextFormat", "textFormat", "enum" }, + { "User", "UserClassHeader", 0, 0 }, + { "User", "UserClassName", 0, 0 }, + { 0, 0, 0, 0 } +}; + +/* + This is the number of supported color groups in a palette, and + supported color roles in a color group. Changing these constants is + dangerous. +*/ +static const int NumColorRoles = 14; + +static bool isTrue( const TQString& val ) +{ + return val.lower() == TQString( "true" ); +} + +static AttributeMap attribute( const TQString& name, const TQString& val ) +{ + AttributeMap attr; + attr.insert( name, val ); + return attr; +} + +static TQString entitize( const TQString& str ) +{ + TQString t = str; + t.replace( '&', TQString("&") ); + t.replace( '>', TQString(">") ); + t.replace( '<', TQString("<") ); + t.replace( '"', TQString(""") ); + t.replace( '\'', TQString("'") ); + return t; +} + +TQString Dlg2Ui::alias( const TQString& name ) const +{ + if ( yyAliasMap.contains(name) ) + return yyAliasMap[name]; + else + return name; +} + +TQString Dlg2Ui::opening( const TQString& tag, const AttributeMap& attr ) +{ + TQString t = TQChar( '<' ) + tag; + AttributeMap::ConstIterator a = attr.begin(); + while ( a != attr.end() ) { + t += TQChar( ' ' ) + a.key() + TQString( "=\"" ) + entitize( *a ) + + TQChar( '"' ); + ++a; + } + t += TQChar( '>' ); + return t; +} + +TQString Dlg2Ui::closing( const TQString& tag ) +{ + return opening( TQChar('/') + tag ); +} + +void Dlg2Ui::error( const TQString& message ) +{ + if ( numErrors++ == 0 ) + TQMessageBox::warning( 0, yyFileName, message ); +} + +void Dlg2Ui::syntaxError() +{ + error( TQString("Sorry, I met a random syntax error. I did what I could, but" + " that was not enough." + "<p>You might want to write to" + " <tt>qt-bugs@trolltech.com</tt> about this incident.") ); +} + +TQString Dlg2Ui::getTextValue( const TQDomNode& node ) +{ + if ( node.childNodes().count() > 1 ) { + syntaxError(); + return TQString::null; + } + + if ( node.childNodes().count() == 0 ) + return TQString::null; + + TQDomText child = node.firstChild().toText(); + if ( child.isNull() ) { + syntaxError(); + return TQString::null; + } + TQString t = child.data().stripWhiteSpace(); + t.replace( "\\\\", "\\" ); + t.replace( "\\n", "\n" ); + return t; +} + +TQVariant Dlg2Ui::getValue( const TQDomNodeList& children, const TQString& tagName, + const TQString& type ) +{ + for ( int i = 0; i < (int) children.count(); i++ ) { + TQDomNode n = children.item( i ); + if ( n.toElement().tagName() == tagName ) + return getValue( n.toElement(), tagName, type ); + } + return TQVariant(); +} + +void Dlg2Ui::emitHeader() +{ + yyOut += TQString( "<!DOCTYPE UI><UI version=\"3.0\" stdsetdef=\"1\">\n" ); +} + +void Dlg2Ui::emitFooter() +{ + yyOut += TQString( "</UI>\n" ); +} + +void Dlg2Ui::emitSimpleValue( const TQString& tag, const TQString& value, + const AttributeMap& attr ) +{ + yyOut += yyIndentStr + opening( tag, attr ) + entitize( value ) + + closing( tag ) + TQChar( '\n' ); +} + +void Dlg2Ui::emitOpening( const TQString& tag, const AttributeMap& attr ) +{ + yyOut += yyIndentStr + opening( tag, attr ) + TQChar( '\n' ); + yyIndentStr += TQString( " " ); +} + +void Dlg2Ui::emitClosing( const TQString& tag ) +{ + yyIndentStr.truncate( yyIndentStr.length() - 4 ); + yyOut += yyIndentStr + closing( tag ) + TQChar( '\n' ); +} + +void Dlg2Ui::emitOpeningWidget( const TQString& className ) +{ + AttributeMap attr = attribute( TQString("class"), className ); + if ( yyGridColumn >= 0 ) { + attr.insert( TQString("row"), TQString::number(yyGridRow) ); + attr.insert( TQString("column"), TQString::number(yyGridColumn) ); + yyGridColumn = -1; + } + emitOpening( TQString("widget"), attr ); +} + +TQString Dlg2Ui::widgetClassName( const TQDomElement& e ) +{ + if ( e.tagName() == TQString("User") ) { + return getValue( e.childNodes(), TQString("UserClassName") ) + .toString(); + } else if ( e.tagName() == TQString("DlgWidget") ) { + return TQString( "TQWidget" ); + } else { + return TQString( "TQ" ).append( e.tagName() ); + } +} + +void Dlg2Ui::emitColor( const TQColor& color ) +{ + emitOpening( TQString("color") ); + emitSimpleValue( TQString("red"), TQString::number(color.red()) ); + emitSimpleValue( TQString("green"), TQString::number(color.green()) ); + emitSimpleValue( TQString("blue"), TQString::number(color.blue()) ); + emitClosing( TQString("color") ); +} + +void Dlg2Ui::emitColorGroup( const TQString& name, const TQColorGroup& group ) +{ + emitOpening( name ); + for ( int i = 0; i < NumColorRoles; i++ ) + emitColor( group.color((TQColorGroup::ColorRole) i) ); + emitClosing( name ); +} + +void Dlg2Ui::emitVariant( const TQVariant& val, const TQString& stringType ) +{ + if ( val.isValid() ) { + switch ( val.type() ) { + case TQVariant::String: + emitSimpleValue( stringType, val.toString() ); + break; + case TQVariant::CString: + emitSimpleValue( TQString("cstring"), val.toString() ); + break; + case TQVariant::Bool: + emitSimpleValue( TQString("bool"), + TQString(val.toBool() ? "true" : "false") ); + break; + case TQVariant::Int: + case TQVariant::UInt: + emitSimpleValue( TQString("number"), val.toString() ); + break; + case TQVariant::Rect: + emitOpening( TQString("rect") ); + emitSimpleValue( TQString("x"), TQString::number(val.toRect().x()) ); + emitSimpleValue( TQString("y"), TQString::number(val.toRect().y()) ); + emitSimpleValue( TQString("width"), + TQString::number(val.toRect().width()) ); + emitSimpleValue( TQString("height"), + TQString::number(val.toRect().height()) ); + emitClosing( TQString("rect") ); + break; + case TQVariant::Point: + emitOpening( TQString("point") ); + emitSimpleValue( TQString("x"), TQString::number(val.toPoint().x()) ); + emitSimpleValue( TQString("y"), TQString::number(val.toPoint().y()) ); + emitClosing( TQString("point") ); + break; + case TQVariant::Size: + emitOpening( TQString("size") ); + emitSimpleValue( TQString("width"), + TQString::number(val.toSize().width()) ); + emitSimpleValue( TQString("height"), + TQString::number(val.toSize().height()) ); + emitClosing( TQString("size") ); + break; + case TQVariant::Color: + emitColor( val.toColor() ); + break; + case TQVariant::Font: + emitOpening( TQString("font") ); + emitSimpleValue( TQString("family"), val.toFont().family() ); + emitSimpleValue( TQString("pointsize"), + TQString::number(val.toFont().pointSize()) ); + if ( val.toFont().bold() ) + emitSimpleValue( TQString("bold"), TQChar('1') ); + if ( val.toFont().italic() ) + emitSimpleValue( TQString("italic"), TQChar('1') ); + if ( val.toFont().underline() ) + emitSimpleValue( TQString("underline"), TQChar('1') ); + if ( val.toFont().strikeOut() ) + emitSimpleValue( TQString("strikeout"), TQChar('1') ); + emitClosing( TQString("font") ); + break; + case TQVariant::Palette: + emitOpening( TQString("palette") ); + emitColorGroup( TQString("active"), val.toPalette().active() ); + emitColorGroup( TQString("disabled"), val.toPalette().disabled() ); + emitColorGroup( TQString("inactive"), val.toPalette().inactive() ); + emitClosing( TQString("palette") ); + break; + default: + emitSimpleValue( TQString("fnord"), TQString::null ); + } + } +} + +void Dlg2Ui::emitProperty( const TQString& prop, const TQVariant& val, + const TQString& stringType ) +{ + emitOpening( TQString("property"), attribute(TQString("name"), prop) ); + emitVariant( val, stringType ); + emitClosing( TQString("property") ); +} + +void Dlg2Ui::emitAttribute( const TQString& attr, const TQVariant& val, + const TQString& stringType ) +{ + emitOpening( TQString("attribute"), attribute(TQString("name"), attr) ); + emitVariant( val, stringType ); + emitClosing( TQString("attribute") ); +} + +void Dlg2Ui::emitOpeningLayout( bool needsWidget, const TQString& layoutKind, + const TQString& name, int border, + int autoBorder ) +{ + TQString namex = name; + + if ( namex.isEmpty() ) + namex = TQString( "Layout%1" ).arg( uniqueLayout++ ); + + if ( needsWidget ) { + emitOpeningWidget( TQString("TQLayoutWidget") ); + emitProperty( TQString("name"), namex.latin1() ); + } + emitOpening( layoutKind ); + if ( !needsWidget ) + emitProperty( TQString("name"), namex.latin1() ); + if ( border != 5 ) + emitProperty( TQString("margin"), border ); + if ( autoBorder != 5 ) + emitProperty( TQString("spacing"), autoBorder ); + yyLayoutDepth++; +} + +void Dlg2Ui::flushWidgets() +{ + TQRegExp widgetForLayout( TQString("Q(?:[HV]Box|Grid)") ); + + while ( !yyWidgetMap.isEmpty() ) { + TQString className = widgetClassName( *yyWidgetMap.begin() ); + if ( !widgetForLayout.exactMatch(className) ) { + emitOpeningWidget( className ); + emitWidgetBody( *yyWidgetMap.begin(), FALSE ); + emitClosing( TQString("widget") ); + } + yyWidgetMap.remove( yyWidgetMap.begin() ); + } +} + +void Dlg2Ui::emitClosingLayout( bool needsWidget, const TQString& layoutKind ) +{ + yyLayoutDepth--; + /* + TQt Designer can deal with layouted widgets and with + fixed-position widgets, but not both at the same time. If such a + thing happens, we arbitrarily put the fixed-position widgets in + the layout so that they at least show up in TQt Designer. + */ + if ( yyLayoutDepth == 0 ) + flushWidgets(); + + emitClosing( layoutKind ); + if ( needsWidget ) + emitClosing( TQString("widget") ); +} + +bool Dlg2Ui::isWidgetType( const TQDomElement& e ) +{ + return yyWidgetTypeSet.contains( e.tagName() ); +} + +void Dlg2Ui::emitSpacer( int spacing, int stretch ) +{ + TQString orientationStr; + TQSize sizeHint; + TQString sizeType = TQString( "Fixed" ); + + if ( yyBoxKind == TQString("hbox") ) { + orientationStr = TQString( "Horizontal" ); + sizeHint = TQSize( spacing, 20 ); + } else { + orientationStr = TQString( "Vertical" ); + sizeHint = TQSize( 20, spacing ); + } + if ( stretch > 0 ) + sizeType = TQString( "Expanding" ); + + emitOpening( TQString("spacer") ); + emitProperty( TQString("name"), + TQString("Spacer%1").arg(uniqueSpacer++).latin1() ); + emitProperty( TQString("orientation"), orientationStr, TQString("enum") ); + if ( spacing > 0 ) + emitProperty( TQString("sizeHint"), sizeHint, TQString("qsize") ); + emitProperty( TQString("sizeType"), sizeType, TQString("enum") ); + emitClosing( TQString("spacer") ); +} + +TQString Dlg2Ui::filteredFlags( const TQString& flags, const TQRegExp& filter ) +{ + TQRegExp evil( TQString("[^0-9A-Z_a-z|]") ); + + TQString f = flags; + f.replace( evil, TQString::null ); + TQStringList splitted = TQStringList::split( TQChar('|'), f ); + return splitted.grep( filter ).join( TQChar('|') ); +} + +void Dlg2Ui::emitFrameStyleProperty( int style ) +{ + TQString shape; + TQString shadow; + + switch ( style & TQFrame::MShape ) { + case TQFrame::Box: + shape = TQString( "Box" ); + break; + case TQFrame::Panel: + shape = TQString( "Panel" ); + break; + case TQFrame::WinPanel: + shape = TQString( "WinPanel" ); + break; + case TQFrame::HLine: + shape = TQString( "HLine" ); + break; + case TQFrame::VLine: + shape = TQString( "VLine" ); + break; + case TQFrame::StyledPanel: + shape = TQString( "StyledPanel" ); + break; + case TQFrame::PopupPanel: + shape = TQString( "PopupPanel" ); + break; + case TQFrame::MenuBarPanel: + shape = TQString( "MenuBarPanel" ); + break; + case TQFrame::ToolBarPanel: + shape = TQString( "ToolBarPanel" ); + break; + case TQFrame::LineEditPanel: + shape = TQString( "LineEditPanel" ); + break; + case TQFrame::TabWidgetPanel: + shape = TQString( "TabWidgetPanel" ); + break; + case TQFrame::GroupBoxPanel: + shape = TQString( "GroupBoxPanel" ); + break; + default: + shape = TQString( "NoFrame" ); + } + + switch ( style & TQFrame::MShadow ) { + case TQFrame::Raised: + shadow = TQString( "Raised" ); + break; + case TQFrame::Sunken: + shadow = TQString( "Sunken" ); + break; + default: + shadow = TQString( "Plain" ); + } + + emitProperty( TQString("frameShape"), shape, TQString("enum") ); + emitProperty( TQString("frameShadow"), shadow, TQString("enum") ); +} + +void Dlg2Ui::emitWidgetBody( const TQDomElement& e, bool layouted ) +{ + TQRegExp align( TQString("^(?:Align|WordBreak$)") ); + TQRegExp frameShape( TQString( + "^(?:NoFrame|Box|(?:Win|Styled|Popup|(?:Menu|Tool)Bar)?Panel|" + "[HV]Line)$") ); + TQRegExp frameShadow( TQString( "^(?:Plain|Raised|Sunken)$") ); + TQRegExp numeric( TQString("[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+") ); + TQRegExp connex( TQString( + "\\s*\\[(BaseClass|P(?:ublic|rotected))\\]\\s*([0-9A-Z_a-z]+)\\s*" + "-->\\s*([0-9A-Z_a-z]+)\\s*(\\([^()]*\\))\\s*") ); + TQRegExp qdialogSlots( TQString( + "done\\(\\s*int\\s*\\)|(?:accept|reject)\\(\\s*\\)") ); + + TQString userClassHeader; + TQString userClassName; + TQString parentTagName; + TQString name; + TQString variableName; + TQMap<TQString, int> pp; + + TQDomNode n = e; + while ( !n.isNull() ) { + if ( isWidgetType(n.toElement()) ) { + parentTagName = n.toElement().tagName(); + pp = yyPropertyMap[parentTagName]; + n = n.firstChild(); + } else { + TQString tagName = n.toElement().tagName(); + + TQMap<TQString, int>::ConstIterator p = pp.find( tagName ); + if ( p == pp.end() ) { + /* + These properties are not in the propertyDefs table, + since they are found in many classes anyway and need + to be treated the same in each case. + */ + if ( tagName == TQString("Alignement") || + tagName == TQString("Alignment") ) { + TQString flags = getValue( n.toElement(), tagName ) + .toString(); + flags = filteredFlags( flags, align ); + if ( !flags.isEmpty() ) + emitProperty( TQString("alignment"), flags, + TQString("set") ); + } else if ( tagName == TQString("ItemList") ) { + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + if ( child.toElement().tagName() == TQString("Item") ) { + TQString text = getTextValue( child ); + emitOpening( TQString("item") ); + emitProperty( TQString("text"), text ); + emitClosing( TQString("item") ); + } + child = child.nextSibling(); + } + } + } else { + TQString propertyName( propertyDefs[*p].qtName ); + + if ( propertyName.isEmpty() ) { + /* + These properties are in the propertyDefs table, + but they have no direct TQt equivalent. + */ + if ( parentTagName == TQString("ComboBox") ) { + if ( tagName == TQString("Style") ) { + if ( getTextValue(n) == TQString("ReadWrite") ) + emitProperty( TQString("editable"), + TQVariant(TRUE, 0) ); + } + } else if ( parentTagName == TQString("DlgWidget") ) { + if ( tagName == TQString("Name") ) { + name = getTextValue( n ); + } else if ( tagName == TQString("Rect") ) { + TQRect rect = getValue( n.toElement(), tagName, + TQString("qrect") ) + .toRect(); + if ( !layouted ) + emitProperty( TQString("geometry"), rect, + TQString("qrect") ); + } else if ( tagName == TQString("SignalConnection") ) { + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + if ( child.toElement().tagName() == + TQString("Signal") ) { + TQString text = getTextValue( child ); + if ( connex.exactMatch(text) ) { + DlgConnection c; + c.sender = getValue( + n.parentNode().childNodes(), + TQString("Name") ).toString(); + c.signal = connex.cap( 2 ) + + connex.cap( 4 ); + c.slot = connex.cap( 3 ) + + connex.cap( 4 ); + yyConnections.append( c ); + + if ( connex.cap(1) != + TQString("BaseClass") && + !qdialogSlots.exactMatch(c.slot) ) + yySlots.insert( c.slot, + connex.cap(1) ); + } + } + child = child.nextSibling(); + } + } else if ( tagName == TQString("Variable") ) { + variableName = getTextValue( n ); + } + } else if ( parentTagName == TQString("Frame") ) { + if ( tagName == TQString("Style") ) { + int style = getValue( n.toElement(), tagName, + TQString("integer") ).toInt(); + emitFrameStyleProperty( style ); + } + } else if ( parentTagName == TQString("LCDNumber") ) { + if ( tagName == TQString("Value") ) { + TQString text = getValue( n.toElement(), tagName ) + .toString(); + if ( numeric.exactMatch(text) ) + emitProperty( TQString("value"), + text.toDouble() ); + } + } else if ( parentTagName == TQString("ListView") ) { + if ( tagName == TQString("HeaderInformation") ) { + int columnNo = 1; + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + if ( child.toElement().tagName() == + TQString("Header") ) { + TQString text = getValue( child.childNodes(), + TQString("Text") ) + .toString(); + if ( text.isEmpty() ) + text = TQString( "Column %1" ) + .arg( columnNo ); + emitOpening( TQString("column") ); + emitProperty( TQString("text"), text ); + emitClosing( TQString("column") ); + } + child = child.nextSibling(); + columnNo++; + } + } + } else if ( parentTagName == TQString("TabBar") ) { + if ( tagName == TQString("TabNames") ) { + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + if ( child.toElement().tagName() == + TQString("Tab") ) { + TQString text = getTextValue( child ); + emitOpeningWidget( TQString("TQWidget") ); + emitProperty( TQString("name"), "tab" ); + emitAttribute( TQString("title"), text ); + emitClosing( TQString("widget") ); + } + child = child.nextSibling(); + } + } + } else if ( parentTagName == TQString("User") ) { + if ( tagName == TQString("UserClassHeader") ) { + userClassHeader = getTextValue( n ); + } else if ( tagName == TQString("UserClassName") ) { + userClassName = getTextValue( n ); + } + } + } else { + /* + These properties are in the propertyDefs table; + they have a direct TQt equivalent. + */ + TQString type( propertyDefs[*p].type ); + TQVariant val = getValue( n.toElement(), tagName, type ); + + if ( type == TQString("qstring") ) + type = TQString( "string" ); + + bool omit = FALSE; + if ( propertyName == TQString("backgroundOrigin") && + val.toString() == TQString("WidgetOrigin") ) + omit = TRUE; + if ( propertyName == TQString("enabled") && val.toBool() ) + omit = TRUE; + if ( propertyName == TQString("minimumSize") && + val.toSize() == TQSize(-1, -1) ) + omit = TRUE; + if ( propertyName == TQString("maximumSize") && + val.toSize() == TQSize(32767, 32767) ) + omit = TRUE; + + if ( !omit ) + emitProperty( propertyName, val, type ); + } + } + n = n.nextSibling(); + } + } + + if ( !variableName.isEmpty() ) { + yyAliasMap.insert( name, variableName ); + name = variableName; + } + if ( !name.isEmpty() ) + emitProperty( TQString("name"), name.latin1() ); + + if ( !userClassName.isEmpty() ) + yyCustomWidgets.insert( userClassName, userClassHeader ); +} + +bool Dlg2Ui::checkTagName( const TQDomElement& e, const TQString& tagName ) +{ + bool ok = ( e.tagName() == tagName ); + if ( !ok ) + syntaxError(); + return ok; +} + +TQString Dlg2Ui::normalizeType( const TQString& type ) +{ + TQString t = type; + if ( t.isEmpty() || t == TQString("enum") || t == TQString( "qcstring" ) || + t == TQString("set") ) + t = TQString( "qstring" ); + return t; +} + +TQVariant Dlg2Ui::getValue( const TQDomElement& e, const TQString& tagName, + const TQString& type ) +{ + TQVariant val; + + if ( e.tagName() != tagName ) + return val; + + TQString t = e.attributes().namedItem( "type" ).toAttr().value(); + if ( normalizeType(t) != normalizeType(type) ) + return val; + + if ( type == TQString("integer") ) { + return getTextValue( e ).toInt(); + } else if ( type == TQString("boolean") ) { + return TQVariant( isTrue(getTextValue(e)), 0 ); + } else if ( type == TQString("double") ) { + return getTextValue( e ).toDouble(); + } else if ( type == TQString("qcstring") ) { + return getTextValue( e ).latin1(); + } else if ( type == TQString("enum") || type == TQString("qstring") || + type == TQString("set") ) { + return getTextValue( e ); + } else { + TQDomNodeList children = e.childNodes(); + + if ( type == TQString("qsize") ) { + int width = getValue( children, TQString("Width"), + TQString("integer") ).toInt(); + int height = getValue( children, TQString("Height"), + TQString("integer") ).toInt(); + return TQSize( width, height ); + } else if ( type == TQString("qrect") ) { + int x = getValue( children, TQString("X"), TQString("integer") ) + .toInt(); + int y = getValue( children, TQString("Y"), TQString("integer") ) + .toInt(); + int width = getValue( children, TQString("Width"), + TQString("integer") ).toInt(); + int height = getValue( children, TQString("Height"), + TQString("integer") ).toInt(); + return TQRect( x, y, width, height ); + } else if ( type == TQString("qpoint") ) { + int x = getValue( children, TQString("X"), TQString("integer") ) + .toInt(); + int y = getValue( children, TQString("Y"), TQString("integer") ) + .toInt(); + return TQPoint( x, y ); + } else if ( type == TQString("qpalette") ) { + TQColorGroup active = getValue( children, TQString("Active"), + TQString("qcolorgroup") ) + .toColorGroup(); + TQColorGroup disabled = getValue( children, TQString("Disabled"), + TQString("qcolorgroup") ) + .toColorGroup(); + TQColorGroup inactive = getValue( children, TQString("Inactive"), + TQString("qcolorgroup") ) + .toColorGroup(); + return TQPalette( active, disabled, inactive ); + } else if ( type == TQString("qfont") ) { + TQString family = getValue( children, TQString("Family"), + TQString("qstring") ).toString(); + int pointSize = getValue( children, TQString("PointSize"), + TQString("integer") ).toInt(); + int weight = getValue( children, TQString("weight"), + TQString("integer") ).toInt(); + bool italic = getValue( children, TQString("Italic"), + TQString("boolean") ).toBool(); + bool underline = getValue( children, TQString("Underline"), + TQString("boolean") ).toBool(); + bool strikeOut = getValue( children, TQString("StrikeOut"), + TQString("boolean") ).toBool(); + int styleHint = getValue( children, TQString("StyleHint"), + TQString("integer") ).toInt(); + + TQFont f; + if ( !family.isEmpty() ) + f.setFamily( family ); + if ( pointSize != 0 ) + f.setPointSize( pointSize ); + if ( weight != 0 ) + f.setWeight( weight ); + f.setItalic( italic ); + f.setUnderline( underline ); + f.setStrikeOut( strikeOut ); + if ( styleHint != 0 ) + f.setStyleHint( (TQFont::StyleHint) styleHint ); + return f; + } else if ( type == TQString("qcolor") ) { + // if any component missing, zero is to be assumed + int red = getValue( children, TQString("Red"), TQString("integer") ) + .toInt(); + int green = getValue( children, TQString("Green"), + TQString("integer") ).toInt(); + int blue = getValue( children, TQString("Blue"), TQString("integer") ) + .toInt(); + return TQColor( red, green, blue ); + } else if ( type == TQString("qcolorgroup") ) { + static const TQColorGroup::ColorRole roles[NumColorRoles] = { + TQColorGroup::Foreground, TQColorGroup::Button, + TQColorGroup::Light, TQColorGroup::Midlight, TQColorGroup::Dark, + TQColorGroup::Mid, TQColorGroup::Text, TQColorGroup::BrightText, + TQColorGroup::ButtonText, TQColorGroup::Base, + TQColorGroup::Background, TQColorGroup::Shadow, + TQColorGroup::Highlight, TQColorGroup::HighlightedText + }; + static const char * const roleNames[NumColorRoles] = { + "Foreground", "Button", "Light", "MidLight", "Dark", "Mid", + "Text", "BrightText", "ButtonText", "Base", "Background", + "Shadow", "HighLighted", "HighLightedText" + }; + TQColorGroup group; + + for ( int i = 0; i < NumColorRoles; i++ ) + group.setColor( roles[i], + getValue(children, TQString(roleNames[i]), + TQString("qcolor")).toColor() ); + return group; + } else { + syntaxError(); + } + } + return val; +} + +void Dlg2Ui::matchDialogCommon( const TQDomElement& dialogCommon ) +{ + if ( !checkTagName(dialogCommon, TQString("DialogCommon")) ) + return; + + TQString sourceDir; + TQString classHeader; + TQString classSource; + TQString dataHeader; + TQString dataSource; + TQString dataName; + TQString windowBaseClass( "TQDialog" ); + bool isCustom = FALSE; + TQString customBaseHeader; + TQString windowCaption; + + yyClassName = "Form1"; + + TQDomNode n = dialogCommon.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + TQString val = getTextValue( n ); + + if ( tagName == TQString("SourceDir") ) { + sourceDir = val; + } else if ( tagName == TQString("ClassHeader") ) { + classHeader = val; + } else if ( tagName == TQString("ClassSource") ) { + classSource = val; + } else if ( tagName == TQString("ClassName") ) { + yyClassName = val; + } else if ( tagName == TQString("DataHeader") ) { + dataHeader = val; + } else if ( tagName == TQString("DataSource") ) { + dataSource = val; + } else if ( tagName == TQString("DataName") ) { + dataName = val; + } else if ( tagName == TQString("WindowBaseClass") ) { + if ( val == TQString("Custom") ) + isCustom = TRUE; + else + windowBaseClass = val; + } else if ( tagName == TQString("IsModal") ) { + } else if ( tagName == TQString("CustomBase") ) { + windowBaseClass = val; + } else if ( tagName == TQString("CustomBaseHeader") ) { + customBaseHeader = val; + } else if ( tagName == TQString("WindowCaption") ) { + windowCaption = val; + } + n = n.nextSibling(); + } + + emitSimpleValue( TQString("class"), yyClassName ); + emitOpeningWidget( windowBaseClass ); + + if ( windowCaption.isEmpty() ) + windowCaption = yyClassName; + emitProperty( TQString("name"), yyClassName.latin1() ); + emitProperty( TQString("caption"), windowCaption ); + + if ( isCustom ) + yyCustomWidgets.insert( windowBaseClass, customBaseHeader ); +} + +bool Dlg2Ui::needsTQLayoutWidget( const TQDomElement& e ) +{ + TQRegExp widgetExists( TQString("WidgetLayout|Layout_Widget") ); + + // we should also check that the widget is not a TQHBox, TQVBox, or TQGrid + TQString grandpa = e.parentNode().parentNode().toElement().tagName(); + return !widgetExists.exactMatch( grandpa ); +} + +void Dlg2Ui::matchBoxLayout( const TQDomElement& boxLayout ) +{ + TQString directionStr; + TQString prevBoxKind = yyBoxKind; + int border = 5; + int autoBorder = 5; + TQString name; + bool needsWidget = needsTQLayoutWidget( boxLayout ); + bool opened = FALSE; + + TQDomNode n = boxLayout.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + + if ( tagName == TQString("Children") ) { + if ( !opened ) { + emitOpeningLayout( needsWidget, yyBoxKind, name, border, + autoBorder ); + if ( !directionStr.isEmpty() ) + emitProperty( TQString("direction"), directionStr, + TQString("enum") ); + opened = TRUE; + } + matchLayout( n.toElement() ); + } else { + TQString val = getTextValue( n ); + + if ( tagName == TQString("Direction") ) { + if ( val == TQString("LeftToRight") ) { + yyBoxKind = TQString( "hbox" ); + } else if ( val == TQString("RightToLeft") ) { + directionStr = val; + yyBoxKind = TQString( "hbox" ); + } else if ( val == TQString("TopToBottom") ) { + yyBoxKind = TQString( "vbox" ); + } else if ( val == TQString("BottomToTop") ) { + directionStr = val; + yyBoxKind = TQString( "vbox" ); + } else { + syntaxError(); + } + } else if ( tagName == TQString("Border") ) { + border = val.toInt(); + } else if ( tagName == TQString("AutoBorder") ) { + autoBorder = val.toInt(); + } else if ( tagName == TQString("Name") ) { + name = val; + } + } + + n = n.nextSibling(); + } + if ( opened ) { + emitClosingLayout( needsWidget, yyBoxKind ); + yyBoxKind = prevBoxKind; + } +} + +void Dlg2Ui::matchBoxSpacing( const TQDomElement& boxSpacing ) +{ + int spacing = 7; + + TQDomNode n = boxSpacing.firstChild(); + while ( !n.isNull() ) { + TQString val = getTextValue( n ); + + if ( n.toElement().tagName() == TQString("Spacing") ) + spacing = val.toInt(); + n = n.nextSibling(); + } + emitSpacer( spacing, 0 ); +} + +void Dlg2Ui::matchBoxStretch( const TQDomElement& boxStretch ) +{ + int stretch = 1; + + TQDomNode n = boxStretch.firstChild(); + while ( !n.isNull() ) { + TQString val = getTextValue( n ); + + if ( n.toElement().tagName() == TQString("Stretch") ) + stretch = val.toInt(); + n = n.nextSibling(); + } + emitSpacer( 0, stretch ); +} + +void Dlg2Ui::matchGridLayout( const TQDomElement& gridLayout ) +{ + int oldGridRow = yyGridRow; + int oldGridColumn = yyGridColumn; + int border = 5; + int autoBorder = 5; + TQString name; + TQString menu; + bool needsWidget = needsTQLayoutWidget( gridLayout ); + bool opened = FALSE; + + TQDomNode n = gridLayout.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + + if ( tagName == TQString("Children") ) { + if ( !opened ) { + emitOpeningLayout( needsWidget, TQString("grid"), name, border, + autoBorder ); + yyGridRow = -1; + yyGridColumn = -1; + opened = TRUE; + } + matchLayout( n.toElement() ); + } else { + if ( tagName == TQString("Border") ) { + border = getTextValue( n ).toInt(); + } else if ( tagName == TQString("AutoBorder") ) { + autoBorder = getTextValue( n ).toInt(); + } else if ( tagName == TQString("Name") ) { + name = getTextValue( n ); + } else if ( tagName == TQString("Menu") ) { + menu = getTextValue( n ); + } + } + n = n.nextSibling(); + } + if ( opened ) + emitClosingLayout( needsWidget, TQString("grid") ); + yyGridRow = oldGridRow; + yyGridColumn = oldGridColumn; +} + +void Dlg2Ui::matchGridRow( const TQDomElement& gridRow ) +{ + yyGridRow++; + + TQDomNode n = gridRow.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + + if ( tagName == TQString("Children") ) { + yyGridColumn = 0; + matchLayout( n.toElement() ); + } + n = n.nextSibling(); + } +} + +void Dlg2Ui::matchGridSpacer( const TQDomElement& gridSpacer ) +{ + if ( !gridSpacer.firstChild().isNull() ) + syntaxError(); +} + +void Dlg2Ui::matchLayoutWidget( const TQDomElement& layoutWidget ) +{ + TQDomElement children; + TQString widget; + + TQDomNode n = layoutWidget.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + + if ( tagName == TQString("Children") ) + children = n.toElement(); + else if ( tagName == TQString("Widget") ) + widget = getTextValue( n ); + n = n.nextSibling(); + } + + if ( !widget.isEmpty() ) { + TQMap<TQString, TQDomElement>::Iterator w = yyWidgetMap.find( widget ); + if ( w == yyWidgetMap.end() ) { + syntaxError(); + } else { + TQString className = widgetClassName( *w ); + if ( className == TQString("TQHBox") || + className == TQString("TQVBox") ) { + bool needsWidget = needsTQLayoutWidget( layoutWidget ); + + TQString prevBoxKind = yyBoxKind; + yyBoxKind = className.mid( 1 ).lower(); + + int spacing = getValue( (*w).childNodes(), TQString("Spacing"), + TQString("integer") ).toInt(); + if ( spacing < 1 ) + spacing = 5; + + emitOpeningLayout( needsWidget, yyBoxKind, widget, 0, spacing ); + if ( !children.isNull() ) + matchLayout( children ); + emitClosingLayout( needsWidget, yyBoxKind ); + yyBoxKind = prevBoxKind; + } else if ( className == TQString("TQGrid") ) { + bool needsWidget = needsTQLayoutWidget( layoutWidget ); + int n = 0; + + TQString direction = getValue( (*w).childNodes(), + TQString("Direction") ).toString(); + int rowsCols = getValue( (*w).childNodes(), TQString("RowCols"), + TQString("integer") ).toInt(); + if ( rowsCols == 0 ) + rowsCols = getValue( (*w).childNodes(), + TQString("RowsCols"), + TQString("integer") ).toInt(); + if ( rowsCols < 1 ) + rowsCols = 5; + int spacing = getValue( (*w).childNodes(), TQString("Spacing"), + TQString("integer") ).toInt(); + if ( spacing < 1 ) + spacing = 5; + + emitOpeningLayout( needsWidget, TQString("grid"), widget, 0, + spacing ); + + TQDomNode child = children.firstChild(); + while ( !child.isNull() ) { + if ( direction == TQString("Vertical") ) { + yyGridColumn = n / rowsCols; + yyGridRow = n % rowsCols; + } else { + yyGridColumn = n % rowsCols; + yyGridRow = n / rowsCols; + } + matchBox( child.toElement() ); + n++; + child = child.nextSibling(); + } + yyGridColumn = -1; + yyGridRow = -1; + emitClosingLayout( needsWidget, TQString("grid") ); + } else { + emitOpeningWidget( widgetClassName(*w) ); + emitWidgetBody( *w, TRUE ); + if ( !children.isNull() ) + matchLayout( children ); + emitClosing( TQString("widget") ); + } + yyWidgetMap.remove( w ); + } + } +} + +void Dlg2Ui::matchBox( const TQDomElement& box ) +{ + /* + What is this jump table doing in here? + */ + static const struct { + const char *tagName; + void (Dlg2Ui::*matchFunc)( const TQDomElement& ); + } jumpTable[] = { + { "Box_Layout", &Dlg2Ui::matchBoxLayout }, + { "Box_Spacing", &Dlg2Ui::matchBoxSpacing }, + { "Box_Stretch", &Dlg2Ui::matchBoxStretch }, + { "Grid_Layout", &Dlg2Ui::matchGridLayout }, + { "Grid_Row", &Dlg2Ui::matchGridRow }, + { "Grid_Spacer", &Dlg2Ui::matchGridSpacer }, + { "Layout_Widget", &Dlg2Ui::matchLayoutWidget }, + { 0, 0 } + }; + + int i = 0; + while ( jumpTable[i].tagName != 0 ) { + if ( TQString(jumpTable[i].tagName) == box.tagName() ) { + (this->*jumpTable[i].matchFunc)( box ); + break; + } + i++; + } + if ( jumpTable[i].tagName == 0 ) + syntaxError(); +} + +void Dlg2Ui::matchLayout( const TQDomElement& layout ) +{ + int column = yyGridColumn; + + TQDomNode n = layout.firstChild(); + while ( !n.isNull() ) { + if ( column != -1 ) + yyGridColumn = column++; + matchBox( n.toElement() ); + n = n.nextSibling(); + } +} + +void Dlg2Ui::matchWidgetLayoutCommon( const TQDomElement& widgetLayoutCommon ) +{ + TQDomNodeList children = widgetLayoutCommon.childNodes(); + + /* + Since we do not respect the spacing and margins specified in + the .dlg file, the specified geometry is slightly wrong (too + small). It still seems to be better to take it in. + */ +#if 1 + TQPoint initialPos = getValue( children, TQString("InitialPos"), + TQString("qpoint") ).toPoint(); + TQSize size = getValue( children, TQString("Size"), TQString("qsize") ) + .toSize(); +#endif + TQSize minSize = getValue( children, TQString("MinSize"), TQString("qsize") ) + .toSize(); + TQSize maxSize = getValue( children, TQString("MaxSize"), TQString("qsize") ) + .toSize(); + +#if 1 + if ( initialPos == TQPoint(-1, -1) ) + initialPos = TQPoint( 0, 0 ); + + emitProperty( TQString("geometry"), TQRect(initialPos, size) ); +#endif + if ( minSize != TQSize(-1, -1) ) + emitProperty( TQString("minimumSize"), minSize ); + if ( maxSize != TQSize(32767, 32767) ) + emitProperty( TQString("maximumSize"), maxSize ); +} + +void Dlg2Ui::matchWidget( const TQDomElement& widget ) +{ + TQString name; + + TQDomNode n = widget; + while ( !n.isNull() ) { + if ( isWidgetType(n.toElement()) ) { + n = n.firstChild(); + } else { + if ( n.toElement().tagName() == TQString("Name") ) { + name = getTextValue( n ); + break; + } + n = n.nextSibling(); + } + } + if ( name.isEmpty() ) + name = TQString( "Widget%1" ).arg( uniqueWidget++ ); + + if ( yyWidgetMap.contains(name) ) + syntaxError(); + yyWidgetMap.insert( name, widget ); +} + +void Dlg2Ui::matchWidgets( const TQDomElement& widgets ) +{ + TQDomNode n = widgets.firstChild(); + while ( !n.isNull() ) { + matchWidget( n.toElement() ); + n = n.nextSibling(); + } +} + +void Dlg2Ui::matchTabOrder( const TQDomElement& tabOrder ) +{ + TQDomNode n = tabOrder.firstChild(); + while ( !n.isNull() ) { + if ( n.toElement().tagName() == TQString("Widget") ) + yyTabStops.append( getTextValue(n.toElement()) ); + n = n.nextSibling(); + } +} + +void Dlg2Ui::matchWidgetLayout( const TQDomElement& widgetLayout ) +{ + if ( !checkTagName(widgetLayout, TQString("WidgetLayout")) ) + return; + + TQDomNode n = widgetLayout.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + + if ( tagName == TQString("WidgetLayoutCommon") ) { + matchWidgetLayoutCommon( n.toElement() ); + } else if ( tagName == TQString("Widgets") ) { + matchWidgets( n.toElement() ); + } else if ( tagName == TQString("TabOrder") ) { + matchTabOrder( n.toElement() ); + } else if ( tagName == TQString("Layout") ) { + matchLayout( n.toElement() ); + } + n = n.nextSibling(); + } +} + +void Dlg2Ui::matchDialog( const TQDomElement& dialog ) +{ + if ( !checkTagName(dialog, TQString("Dialog")) ) + return; + + TQDomNodeList nodes = dialog.childNodes(); + if ( nodes.count() == 2 ) { + matchDialogCommon( nodes.item(0).toElement() ); + matchWidgetLayout( nodes.item(1).toElement() ); + flushWidgets(); + emitClosing( TQString("widget") ); + + if ( !yyCustomWidgets.isEmpty() ) { + emitOpening( TQString("customwidgets") ); + + TQMap<TQString, TQString>::Iterator w = yyCustomWidgets.begin(); + while ( w != yyCustomWidgets.end() ) { + emitOpening( TQString("customwidget") ); + emitSimpleValue( TQString("class"), w.key() ); + if ( !(*w).isEmpty() ) + emitSimpleValue( TQString("header"), *w, + attribute(TQString("location"), + TQString("local")) ); + emitClosing( TQString("customwidget") ); + ++w; + } + emitClosing( TQString("customwidgets") ); + } + + if ( yyConnections.count() + yySlots.count() > 0 ) { + emitOpening( TQString("connections") ); + + TQValueList<DlgConnection>::Iterator c = yyConnections.begin(); + while ( c != yyConnections.end() ) { + emitOpening( TQString("connection") ); + emitSimpleValue( TQString("sender"), alias((*c).sender) ); + emitSimpleValue( TQString("signal"), (*c).signal ); + emitSimpleValue( TQString("receiver"), yyClassName ); + emitSimpleValue( TQString("slot"), (*c).slot ); + emitClosing( TQString("connection") ); + ++c; + } + + TQMap<TQString, TQString>::Iterator s = yySlots.begin(); + while ( s != yySlots.end() ) { + AttributeMap attr; + attr.insert( TQString("access"), *s ); + attr.insert( TQString("language"), TQString("C++") ); + attr.insert( TQString("returntype"), TQString("void") ); + emitSimpleValue( TQString("slot"), s.key(), attr ); + ++s; + } + emitClosing( TQString("connections") ); + } + + if ( !yyTabStops.isEmpty() ) { + emitOpening( TQString("tabstops") ); + TQStringList::ConstIterator t = yyTabStops.begin(); + while ( t != yyTabStops.end() ) { + emitSimpleValue( TQString("tabstop"), alias(*t) ); + ++t; + } + emitClosing( TQString("tabstops") ); + } + } +} + +TQStringList Dlg2Ui::convertTQtArchitectDlgFile( const TQString& fileName ) +{ + int i; + + yyFileName = fileName; + yyLayoutDepth = 0; + yyGridRow = -1; + yyGridColumn = -1; + + numErrors = 0; + uniqueLayout = 1; + uniqueSpacer = 1; + uniqueWidget = 1; + + i = 0; + while ( widgetTypes[i] != 0 ) { + yyWidgetTypeSet.insert( TQString(widgetTypes[i]), 0 ); + i++; + } + + i = 0; + while ( propertyDefs[i].widgetName != 0 ) { + yyPropertyMap[TQString(propertyDefs[i].widgetName)] + .insert( TQString(propertyDefs[i].architectName), i ); + i++; + } + + TQDomDocument doc( TQString("TQtArch") ); + TQFile f( fileName ); + if ( !f.open(IO_ReadOnly) ) { + return TQStringList(); + } + if ( !doc.setContent(&f) ) { + TQString firstLine; + f.at( 0 ); + f.readLine( firstLine, 128 ); + firstLine = firstLine.stripWhiteSpace(); + if ( firstLine.startsWith(TQString("DlgEdit:v1")) ) { + error( TQString("This file is a TQt Architect 1.x file. TQt Designer" + " can only read XML dialog files, as generated by TQt" + " Architect 2.1 or above." + "<p>To convert this file to the right format," + " first install TQt Architect 2.1 (available at" + " <tt>http://qtarch.sourceforge.net/</tt>). Use the" + " <i>update20.pl</i> Perl script to update the file" + " to the 2.0 format. Load that file in TQt" + " Architect and save it. The file should now be in" + " XML format and loadable in TQt Designer.") ); + } else if ( firstLine.startsWith(TQString("DlgEdit::v2")) ) { + error( TQString("This file is a TQt Architect 2.0 file. TQt Designer" + " can only read XML dialog files, as generated by TQt" + " Architect 2.1 or above." + "<p>To convert this file to the right format," + " first install TQt Architect 2.1 (available at" + " <tt>http://qtarch.sourceforge.net/</tt>). Load the" + " 2.0 file in TQt Architect and save it. The file" + " should now be in XML format and loadable in TQt" + " Designer.") ); + } else { + error( TQString("The file you gave me is not an XML file, as far as" + " I can tell.") ); + } + + f.close(); + return TQStringList(); + } + f.close(); + + TQDomElement root = doc.documentElement(); + if ( root.tagName() != TQString("TQtArch") || + root.attributeNode("type").value() != TQString("Dialog") ) { + error( TQString("The file you gave me is not a TQt Architect dialog" + " file.") ); + return TQStringList(); + } + + emitHeader(); + + TQDomNode n = root.firstChild(); + while ( !n.isNull() ) { + // there should be only one + matchDialog( n.toElement() ); + n = n.nextSibling(); + } + + emitFooter(); + + TQFile outf; + TQString outFileName = yyClassName + TQString( ".ui" ); + + outf.setName( outFileName ); + if ( !outf.open(IO_WriteOnly) ) { + qWarning( "dlg2ui: Could not open output file '%s'", + outFileName.latin1() ); + return TQStringList(); + } + + TQTextStream out; + out.setEncoding( TQTextStream::Latin1 ); + out.setDevice( &outf ); + out << yyOut; + outf.close(); + + return TQStringList( outFileName ); +} diff --git a/tools/designer/plugins/dlg/dlg2ui.h b/tools/designer/plugins/dlg/dlg2ui.h new file mode 100644 index 000000000..2fc219c64 --- /dev/null +++ b/tools/designer/plugins/dlg/dlg2ui.h @@ -0,0 +1,144 @@ +/********************************************************************** +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef DLG2UI_H +#define DLG2UI_H + +#include <qdom.h> +#include <qmap.h> +#include <qstring.h> +#include <qvariant.h> + +typedef TQMap<TQString, TQString> AttributeMap; + +struct DlgConnection +{ + TQString sender; + TQString signal; + TQString slot; + +#if defined(Q_FULL_TEMPLATE_INSTANTIATION) + bool operator==( const DlgConnection& ) const { + return sender == sender && signal == signal && slot == slot; + } +#endif +}; + +class Dlg2Ui +{ +public: + TQStringList convertTQtArchitectDlgFile( const TQString& fileName ); + +private: + TQString alias( const TQString& name ) const; + TQString opening( const TQString& tag, + const AttributeMap& attr = AttributeMap() ); + TQString closing( const TQString& tag ); + void error( const TQString& message ); + void syntaxError(); + TQString getTextValue( const TQDomNode& node ); + TQVariant getValue( const TQDomNodeList& children, const TQString& tagName, + const TQString& type = "qstring" ); + void emitHeader(); + void emitFooter(); + void emitSimpleValue( const TQString& tag, const TQString& value, + const AttributeMap& attr = AttributeMap() ); + void emitOpening( const TQString& tag, + const AttributeMap& attr = AttributeMap() ); + void emitClosing( const TQString& tag ); + void emitOpeningWidget( const TQString& className ); + TQString widgetClassName( const TQDomElement& e ); + void emitColor( const TQColor& color ); + void emitColorGroup( const TQString& name, const TQColorGroup& group ); + void emitVariant( const TQVariant& val, + const TQString& stringType = "string" ); + void emitProperty( const TQString& prop, const TQVariant& val, + const TQString& stringType = "string" ); + void emitAttribute( const TQString& attr, const TQVariant& val, + const TQString& stringType = "string" ); + void emitOpeningLayout( bool needsWidget, const TQString& layoutKind, + const TQString& name, int border, int autoBorder ); + void flushWidgets(); + void emitClosingLayout( bool needsWidget, const TQString& layoutKind ); + bool isWidgetType( const TQDomElement& e ); + void emitSpacer( int spacing, int stretch ); + TQString filteredFlags( const TQString& flags, const TQRegExp& filter ); + void emitFrameStyleProperty( int style ); + void emitWidgetBody( const TQDomElement& e, bool layouted ); + bool checkTagName( const TQDomElement& e, const TQString& tagName ); + TQString normalizeType( const TQString& type ); + TQVariant getValue( const TQDomElement& e, const TQString& tagName, + const TQString& type = "qstring" ); + void matchDialogCommon( const TQDomElement& dialogCommon ); + bool needsTQLayoutWidget( const TQDomElement& e ); + void matchBoxLayout( const TQDomElement& boxLayout ); + void matchBoxSpacing( const TQDomElement& boxSpacing ); + void matchBoxStretch( const TQDomElement& boxStretch ); + void matchGridLayout( const TQDomElement& gridLayout ); + void matchGridRow( const TQDomElement& gridRow ); + void matchGridSpacer( const TQDomElement& gridSpacer ); + void matchLayoutWidget( const TQDomElement& layoutWidget ); + void matchBox( const TQDomElement& box ); + void matchLayout( const TQDomElement& layout ); + void matchWidgetLayoutCommon( const TQDomElement& widgetLayoutCommon ); + void matchWidget( const TQDomElement& widget ); + void matchWidgets( const TQDomElement& widgets ); + void matchTabOrder( const TQDomElement& tabOrder ); + void matchWidgetLayout( const TQDomElement& widgetLayout ); + void matchDialog( const TQDomElement& dialog ); + + TQString yyOut; + TQString yyIndentStr; + TQString yyFileName; + TQString yyClassName; + TQMap<TQString, int> yyWidgetTypeSet; + TQMap<TQString, TQMap<TQString, int> > yyPropertyMap; + TQMap<TQString, TQDomElement> yyWidgetMap; + TQMap<TQString, TQString> yyCustomWidgets; + TQValueList<DlgConnection> yyConnections; + TQMap<TQString, TQString> yySlots; + TQMap<TQString, TQString> yyAliasMap; + TQStringList yyTabStops; + TQString yyBoxKind; + int yyLayoutDepth; + int yyGridRow; + int yyGridColumn; + + int numErrors; + int uniqueLayout; + int uniqueSpacer; + int uniqueWidget; +}; + +#endif diff --git a/tools/designer/plugins/dlg/main.cpp b/tools/designer/plugins/dlg/main.cpp new file mode 100644 index 000000000..886efc827 --- /dev/null +++ b/tools/designer/plugins/dlg/main.cpp @@ -0,0 +1,108 @@ +/********************************************************************** +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include <filterinterface.h> +#include <qapplication.h> + +#include "dlg2ui.h" + +class DlgFilter : public ImportFilterInterface, public TQLibraryInterface +{ +public: + DlgFilter(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface **iface ); + Q_REFCOUNT; + + TQStringList featureList() const; + TQStringList import( const TQString& filter, const TQString& filename ); + + bool init(); + void cleanup(); + bool canUnload() const; +}; + +DlgFilter::DlgFilter() +{ +} + +TQRESULT DlgFilter::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)(ImportFilterInterface*)this; + else if ( uuid == IID_QFeatureList ) + *iface = (TQFeatureListInterface*)this; + else if ( uuid == IID_ImportFilter ) + *iface = (ImportFilterInterface*)this; + else if ( uuid == IID_QLibrary ) + *iface = (TQLibraryInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +TQStringList DlgFilter::featureList() const +{ + TQStringList list; + list << "TQt Architect Dialog Files (*.dlg)" ; + return list; +} + +TQStringList DlgFilter::import( const TQString &, const TQString& filename ) +{ + Dlg2Ui d; + return d.convertTQtArchitectDlgFile( filename ); +} + +bool DlgFilter::init() +{ + return TRUE; +} + +void DlgFilter::cleanup() +{ +} + +bool DlgFilter::canUnload() const +{ + return TRUE; +} + +Q_EXPORT_COMPONENT() +{ + Q_CREATE_INSTANCE( DlgFilter ) +} diff --git a/tools/designer/plugins/glade/glade.pro b/tools/designer/plugins/glade/glade.pro new file mode 100644 index 000000000..c1be0c560 --- /dev/null +++ b/tools/designer/plugins/glade/glade.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +CONFIG += qt warn_on release plugin +HEADERS = glade2ui.h +SOURCES = main.cpp glade2ui.cpp +DESTDIR = ../../../../plugins/designer +DEFINES += QT_INTERNAL_XML +include( ../../../../src/qt_professional.pri ) +TARGET = gladeplugin +INCLUDEPATH += ../../interfaces + + +target.path += $$plugins.path/designer +INSTALLS += target diff --git a/tools/designer/plugins/glade/glade2ui.cpp b/tools/designer/plugins/glade/glade2ui.cpp new file mode 100644 index 000000000..89337eb58 --- /dev/null +++ b/tools/designer/plugins/glade/glade2ui.cpp @@ -0,0 +1,2203 @@ +/********************************************************************** +** +** Converts a Glade .glade file into a .ui file. +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "glade2ui.h" + +#include <qapplication.h> +#include <qfile.h> +#include <qimage.h> +#include <qprogressdialog.h> +#include <qmessagebox.h> +#include <qrect.h> +#include <qregexp.h> +#include <qsizepolicy.h> + +#include <ctype.h> + +static const struct { + const char *gtkName; + const char *qtName; +} classNames[] = { + { "Custom", "Custom" }, + { "GnomeAbout", "TQDialog" }, + { "GnomeApp", "TQMainWindow" }, + { "GnomeCanvas", "TQLabel" }, + { "GnomeColorPicker", "TQComboBox" }, + { "GnomeDateEdit", "TQDateTimeEdit" }, + { "GnomeDialog", "TQDialog" }, + { "GnomeFontPicker", "TQComboBox" }, + { "GnomeIconSelection", "TQIconView" }, + { "GnomePixmap", "TQLabel" }, + { "GnomePropertyBox", "TQDialog" }, + { "GtkAccelLabel", "TQLabel" }, + { "GtkAspectFrame", "TQFrame" }, + { "GtkButton", "TQPushButton" }, + { "GtkCList", "TQListView" }, + { "GtkCTree", "TQListView" }, + { "GtkCheckButton", "TQCheckBox" }, + { "GtkCombo", "TQComboBox" }, + { "GtkDial", "TQDial" }, + { "GtkDialog", "TQDialog" }, + { "GtkEntry", "TQLineEdit" }, + { "GtkFixed", "TQLayoutWidget" }, + { "GtkFrame", "TQFrame" }, + { "GtkHPaned", "TQSplitter" }, + { "GtkHScale", "TQSlider" }, + { "GtkHScrollbar", "TQScrollBar" }, + { "GtkHSeparator", "Line" }, + { "GtkHandleBox", "TQFrame" }, + { "GtkImage", "TQLabel" }, + { "GtkLabel", "TQLabel" }, + { "GtkList", "TQListBox" }, + { "GtkNotebook", "TQTabWidget" }, + { "GtkOptionMenu", "TQComboBox" }, + { "GtkPixmap", "TQLabel" }, + { "GtkPreview", "TQLabel" }, + { "GtkProgressBar", "TQProgressBar" }, + { "GtkRadioButton", "TQRadioButton" }, + { "GtkSpinButton", "TQSpinBox" }, + { "GtkStatusbar", "TQStatusBar" }, + { "GtkText", "TQTextEdit" }, + { "GtkToggleButton", "TQPushButton" }, + { "GtkTree", "TQListView" }, + { "GtkVPaned", "TQSplitter" }, + { "GtkVScale", "TQSlider" }, + { "GtkVScrollbar", "TQScrollBar" }, + { "GtkVSeparator", "Line" }, + { "Placeholder", "TQLabel" }, + { 0, 0 } +}; + +static const struct { + const char *name; + const char *menuText; +} stockMenuItems[] = { + { "ABOUT", "&About" }, + { "CLEAR", "C&lear" }, + { "CLOSE", "&Close" }, + { "CLOSE_WINDOW", "&Close This Window" }, + { "COPY", "&Copy" }, + { "CUT", "C&ut" }, + { "END_GAME", "&End Game" }, + { "EXIT", "E&xit" }, + { "FIND", "&Find..." }, + { "FIND_AGAIN", "Find &Again" }, + { "HINT", "&Hint" }, + { "NEW", "&New" }, + { "NEW_GAME", "&New Game" }, + { "NEW_WINDOW", "Create New &Window" }, + { "OPEN", "&Open..." }, + { "PASTE", "&Paste" }, + { "PAUSE_GAME", "&Pause Game" }, + { "PREFERENCES", "&Preferences..." }, + { "PRINT", "&Print" }, + { "PRINT_SETUP", "Print S&etup..." }, + { "PROPERTIES", "&Properties..." }, + { "REDO", "&Redo" }, + { "REDO_MOVE", "&Redo Move" }, + { "REPLACE", "&Replace..." }, + { "RESTART_GAME", "&Restart Game" }, + { "REVERT", "&Revert" }, + { "SAVE", "&Save" }, + { "SAVE_AS", "Save &As..." }, + { "SCORES", "&Scores..." }, + { "SELECT_ALL", "&Select All" }, + { "UNDO", "&Undo" }, + { "UNDO_MOVE", "&Undo Move" }, + { 0, 0 } +}; + +static const struct { + const char *gtkName; + int qtValue; +} keys[] = { + { "BackSpace", TQt::Key_BackSpace }, + { "Delete", TQt::Key_Delete }, + { "Down", TQt::Key_Down }, + { "End", TQt::Key_End }, + { "Escape", TQt::Key_Escape }, + { "F1", TQt::Key_F1 }, + { "F10", TQt::Key_F10 }, + { "F11", TQt::Key_F11 }, + { "F12", TQt::Key_F12 }, + { "F2", TQt::Key_F2 }, + { "F3", TQt::Key_F3 }, + { "F4", TQt::Key_F4 }, + { "F5", TQt::Key_F5 }, + { "F6", TQt::Key_F6 }, + { "F7", TQt::Key_F7 }, + { "F8", TQt::Key_F8 }, + { "F9", TQt::Key_F9 }, + { "Home", TQt::Key_Home }, + { "Insert", TQt::Key_Insert }, + { "KP_Enter", TQt::Key_Enter }, + { "Left", TQt::Key_Left }, + { "Page_Down", TQt::Key_PageDown }, + { "Page_Up", TQt::Key_PageUp }, + { "Return", TQt::Key_Return }, + { "Right", TQt::Key_Right }, + { "Tab", TQt::Key_Tab }, + { "Up", TQt::Key_Up }, + { "space", TQt::Key_Space }, + { 0, 0 } +}; + +static TQString nonMenuText( const TQString& menuText ) +{ + TQString t; + int len = (int) menuText.length(); + if ( menuText.endsWith(TQString("...")) ) + len -= 3; + for ( int i = 0; i < len; i++ ) { + if ( menuText[i] != TQChar('&') ) + t += menuText[i]; + } + return t; +} + +/* + Some GTK dialog use hyphens in variable names. Let's take no chance. +*/ +static TQString fixedName( const TQString& name ) +{ + const char *latin1 = name.latin1(); + TQString fixed; + + int i = 0; + while ( latin1 != 0 && latin1[i] != '\0' ) { + if ( isalnum(latin1[i]) ) + fixed += name[i]; + else + fixed += TQChar( '_' ); + i++; + } + return fixed; +} + +/* + Returns an hexadecimal rendering of a block of memory. +*/ +static TQString hexed( const char *data, int length ) +{ + TQString t; + for ( int i = 0; i < length; i++ ) { + TQString x; + x.sprintf( "%.2x", (uchar) data[i] ); + t += x; + } + return t; +} + +static bool isTrue( const TQString& val ) +{ + return val.lower() == TQString( "true" ); +} + +static AttributeMap attribute( const TQString& name, const TQString& val ) +{ + AttributeMap attr; + attr.insert( name, val ); + return attr; +} + +static TQString entitize( const TQString& str ) +{ + TQString t = str; + t.replace( '&', TQString("&") ); + t.replace( '>', TQString(">") ); + t.replace( '<', TQString("<") ); + t.replace( '"', TQString(""") ); + t.replace( '\'', TQString("'") ); + return t; +} + +Glade2Ui::Glade2Ui() +{ + int i = 0; + while ( classNames[i].gtkName != 0 ) { + yyClassNameMap.insert( TQString(classNames[i].gtkName), + TQString(classNames[i].qtName) ); + i++; + } + + i = 0; + while ( stockMenuItems[i].name != 0 ) { + yyStockMap.insert( TQString(stockMenuItems[i].name), + TQString(stockMenuItems[i].menuText) ); + i++; + } + + i = 0; + while ( keys[i].gtkName != 0 ) { + yyKeyMap.insert( TQString(keys[i].gtkName), keys[i].qtValue ); + i++; + } +} + +TQString Glade2Ui::imageName( const TQString& fileName ) +{ + return *yyImages.insert( fileName, TQString("image%1").arg(yyImages.count()), + FALSE ); +} + +TQString Glade2Ui::opening( const TQString& tag, const AttributeMap& attr ) +{ + TQString t = TQChar( '<' ) + tag; + AttributeMap::ConstIterator a = attr.begin(); + while ( a != attr.end() ) { + t += TQChar( ' ' ) + a.key() + TQString( "=\"" ) + entitize( *a ) + + TQChar( '"' ); + ++a; + } + t += TQChar( '>' ); + return t; +} + +TQString Glade2Ui::closing( const TQString& tag ) +{ + return opening( TQChar('/') + tag ); +} + +TQString Glade2Ui::atom( const TQString& tag, const AttributeMap& attr ) +{ + TQString t = opening( tag, attr ); + t.insert( t.length() - 1, TQChar('/') ); + return t; +} + +void Glade2Ui::error( const TQString& message ) +{ + if ( numErrors++ == 0 ) + TQMessageBox::warning( 0, yyFileName, message ); +} + +void Glade2Ui::syntaxError() +{ + error( TQString("Sorry, I met a random syntax error. I did what I could, but" + " that was not enough." + "<p>You might want to write to" + " <tt>qt-bugs@trolltech.com</tt> about this incident.") ); +} + +TQString Glade2Ui::getTextValue( const TQDomNode& node ) +{ + if ( node.childNodes().count() > 1 ) { + syntaxError(); + return TQString::null; + } + + if ( node.childNodes().count() == 0 ) + return TQString::null; + + TQDomText t = node.firstChild().toText(); + if ( t.isNull() ) { + syntaxError(); + return TQString::null; + } + return t.data().stripWhiteSpace(); +} + +void Glade2Ui::emitHeader() +{ + yyOut += TQString( "<!DOCTYPE UI><UI version=\"3.0\" stdsetdef=\"1\">\n" ); +} + +void Glade2Ui::emitFooter() +{ + yyOut += TQString( "</UI>\n" ); +} + +void Glade2Ui::emitSimpleValue( const TQString& tag, const TQString& value, + const AttributeMap& attr ) +{ + yyOut += yyIndentStr + opening( tag, attr ) + entitize( value ) + + closing( tag ) + TQChar( '\n' ); +} + +void Glade2Ui::emitOpening( const TQString& tag, const AttributeMap& attr ) +{ + yyOut += yyIndentStr + opening( tag, attr ) + TQChar( '\n' ); + yyIndentStr += TQString( " " ); +} + +void Glade2Ui::emitClosing( const TQString& tag ) +{ + yyIndentStr.truncate( yyIndentStr.length() - 4 ); + yyOut += yyIndentStr + closing( tag ) + TQChar( '\n' ); +} + +void Glade2Ui::emitAtom( const TQString& tag, const AttributeMap& attr ) +{ + yyOut += yyIndentStr + atom( tag, attr ) + TQChar( '\n' ); +} + +void Glade2Ui::emitVariant( const TQVariant& val, const TQString& stringType ) +{ + if ( val.isValid() ) { + switch ( val.type() ) { + case TQVariant::String: + emitSimpleValue( stringType, val.toString() ); + break; + case TQVariant::CString: + emitSimpleValue( TQString("cstring"), val.toString() ); + break; + case TQVariant::Bool: + emitSimpleValue( TQString("bool"), + TQString(val.toBool() ? "true" : "false") ); + break; + case TQVariant::Int: + case TQVariant::UInt: + emitSimpleValue( TQString("number"), val.toString() ); + break; + case TQVariant::Rect: + emitOpening( TQString("rect") ); + emitSimpleValue( TQString("x"), TQString::number(val.toRect().x()) ); + emitSimpleValue( TQString("y"), TQString::number(val.toRect().y()) ); + emitSimpleValue( TQString("width"), + TQString::number(val.toRect().width()) ); + emitSimpleValue( TQString("height"), + TQString::number(val.toRect().height()) ); + emitClosing( TQString("rect") ); + break; + case TQVariant::Size: + emitOpening( TQString("size") ); + emitSimpleValue( TQString("width"), + TQString::number(val.toSize().width()) ); + emitSimpleValue( TQString("height"), + TQString::number(val.toSize().height()) ); + emitClosing( TQString("size") ); + break; + case TQVariant::SizePolicy: + emitOpening( TQString("sizepolicy") ); + emitSimpleValue( TQString("hsizetype"), + TQString::number((int) val.toSizePolicy() + .horData()) ); + emitSimpleValue( TQString("vsizetype"), + TQString::number((int) val.toSizePolicy() + .verData()) ); + emitClosing( TQString("sizepolicy") ); + break; + default: + emitSimpleValue( TQString("fnord"), TQString::null ); + } + } +} + +void Glade2Ui::emitProperty( const TQString& prop, const TQVariant& val, + const TQString& stringType ) +{ + emitOpening( TQString("property"), attribute(TQString("name"), prop) ); + emitVariant( val, stringType ); + emitClosing( TQString("property") ); +} + +void Glade2Ui::emitFontProperty( const TQString& prop, int pointSize, bool bold ) +{ + emitOpening( TQString("property"), attribute(TQString("name"), prop) ); + emitOpening( TQString("font") ); + emitSimpleValue( TQString("pointsize"), TQString::number(pointSize) ); + if ( bold ) + emitSimpleValue( TQString("bold"), TQString("1") ); + emitClosing( TQString("font") ); + emitClosing( TQString("property") ); +} + +void Glade2Ui::emitAttribute( const TQString& prop, const TQVariant& val, + const TQString& stringType ) +{ + emitOpening( TQString("attribute"), attribute(TQString("name"), prop) ); + emitVariant( val, stringType ); + emitClosing( TQString("attribute") ); +} + +static TQString accelerate( const TQString& gtkLabel ) +{ + TQString qtLabel = gtkLabel; + qtLabel.replace( '&', TQString("&&") ); + // close but not tquite right + qtLabel.replace( TQChar('_'), TQChar('&') ); + return qtLabel; +} + +static TQString decelerate( const TQString& gtkLabel ) +{ + TQString qtLabel = gtkLabel; + // ditto + qtLabel.replace( '_', TQString::null ); + return qtLabel; +} + +/* + Converting a GTK widget to a corresponding TQt widget is sometimes + hard. For example, a GtkScrolledWindow should sometimes be converted + into a TQTextView, a TQTextEdit, a TQListView or whatever. What we do + is pretty hackish, but it mostly works. +*/ +TQString Glade2Ui::gtk2qtClass( const TQString& gtkClass, + const TQValueList<TQDomElement>& childWidgets ) +{ + TQRegExp gnomeXEntry( TQString("Gnome(File|Number|Pixmap)?Entry") ); + + TQString qtClass; + + if ( gtkClass == TQString("GtkScrolledWindow") ) { + if ( childWidgets.count() == 1 ) { + TQString g; + bool editable = FALSE; + bool showTitles = TRUE; + + TQDomNode n = childWidgets.first().firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("class") ) { + g = getTextValue( n ); + } else if ( tagName == TQString("editable") ) { + editable = isTrue( getTextValue(n) ); + } else if ( tagName.startsWith(TQString("show_tit")) ) { + showTitles = isTrue( getTextValue(n) ); + } + n = n.nextSibling(); + } + + if ( g == TQString("GnomeCanvas") || + g == TQString("GtkDrawingArea") ) { + qtClass = TQString( "TQLabel" ); + } else if ( g == TQString("GnomeIconList") ) { + qtClass = TQString( "TQIconView" ); + } else if ( g == TQString("GtkCList") ) { + if ( showTitles ) + qtClass = TQString( "TQListView" ); + else + qtClass = TQString( "TQListBox" ); + } else if ( g == TQString("GtkCTree") ) { + qtClass = TQString( "TQListView" ); + } else if ( g == TQString("GtkList") ) { + qtClass = TQString( "TQListBox" ); + } else if ( g == TQString("GtkText") ) { + if ( editable ) + qtClass = TQString( "TQTextEdit" ); + else + qtClass = TQString( "TQTextView" ); + } else if ( g == TQString("GtkTree") ) { + qtClass = TQString( "TQListView" ); + } + // else too bad (qtClass is empty) + } + } else if ( gtkClass == TQString("GtkWindow") ) { + qtClass = TQString( "TQDialog" ); + if ( childWidgets.count() == 1 ) { + TQString g; + + TQDomNode n = childWidgets.first().firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("class") ) + g = getTextValue( n ); + n = n.nextSibling(); + } + if ( g == TQString("GnomeDruid") ) + qtClass = TQString( "TQWizard" ); + } + /* + GnomeEntry and friends are a wrapper around a GtkEntry. We only + want the GtkEntry child. + */ + } else if ( !gnomeXEntry.exactMatch(gtkClass) && + gtkClass != TQString("GtkAlignment") && + gtkClass != TQString("GtkEventBox") ) { + qtClass = yyClassNameMap[gtkClass]; + if ( qtClass.isEmpty() ) + qtClass = TQString( "Unknown" ); + } + return qtClass; +} + +static TQString gtk2qtScrollBarMode( const TQString& scrollbarPolicy ) +{ + if ( scrollbarPolicy.endsWith(TQString("_NEVER")) ) { + return TQString( "AlwaysOff" ); + } else if ( scrollbarPolicy.endsWith(TQString("_ALWAYS")) ) { + return TQString( "AlwaysOn" ); + } else { + return TQString( "Auto" ); + } +} + +static TQString gtk2qtSelectionMode( const TQString& selectionMode ) +{ + if ( selectionMode.endsWith(TQString("_MULTIPLE")) ) + return TQString( "Multi" ); + else if ( selectionMode.endsWith(TQString("_EXTENDED")) ) + return TQString( "Extended" ); + else + return TQString( "Single" ); +} + +int Glade2Ui::matchAccelOnActivate( const TQDomElement& accel ) +{ + TQString key; + TQString modifiers; + + TQDomNode n = accel.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("key") ) { + key = getTextValue( n ); + if ( !key.startsWith(TQString("GDK_")) ) + return 0; + } else if ( tagName == TQString("modifiers") ) { + modifiers = getTextValue( n ); + } else if ( tagName == TQString("signal") ) { + if ( getTextValue(n) != TQString("activate") ) + return 0; + } + n = n.nextSibling(); + } + + int flags = 0; + + if ( key.length() == 5 ) { + flags = key[4].upper().latin1(); + } else if ( yyKeyMap.contains(key.mid(4)) ) { + flags = yyKeyMap[key.mid(4)]; + } else { + return 0; + } + + if ( modifiers.contains(TQString("_CONTROL_")) ) + flags |= TQt::CTRL; + if ( modifiers.contains(TQString("_SHIFT_")) ) + flags |= TQt::SHIFT; + if ( modifiers.contains(TQString("_MOD1_")) ) + flags |= TQt::ALT; + return flags; +} + +void Glade2Ui::emitGtkMenu( const TQDomElement& menu ) +{ + TQRegExp gnomeuiinfoMenuXItem( TQString("GNOMEUIINFO_MENU_(.+)_ITEM") ); + + TQDomNode n = menu.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("widget") ) { + TQString activateHandler; + TQString gtkClass; + TQString icon; + TQString label; + TQString name; + TQString stockItem; + TQString tooltip; + int qtAccel = 0; + + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + TQString childTagName = child.toElement().tagName(); + if ( childTagName == TQString("accelerator") ) { + qtAccel = matchAccelOnActivate( child.toElement() ); + } else if ( childTagName == TQString("class") ) { + gtkClass = getTextValue( child ); + } else if ( childTagName == TQString("icon") ) { + icon = getTextValue( child ); + } else if ( childTagName == TQString("label") ) { + label = getTextValue( child ); + } else if ( childTagName == TQString("name") ) { + name = getTextValue( child ); + } else if ( childTagName == TQString("signal") ) { + TQString signalName; + TQString signalHandler; + + TQDomNode grandchild = child.firstChild(); + while ( !grandchild.isNull() ) { + TQString grandchildTagName = + grandchild.toElement().tagName(); + if ( grandchildTagName == TQString("handler") ) { + signalHandler = getTextValue( grandchild ); + } else if ( grandchildTagName == TQString("name") ) { + signalName = getTextValue( grandchild ); + } + grandchild = grandchild.nextSibling(); + } + if ( signalName == TQString("activate") ) + activateHandler = signalHandler; + } else if ( childTagName == TQString("stock_item") ) { + stockItem = getTextValue( child ); + } else if ( childTagName == TQString("tooltip") ) { + tooltip = getTextValue( child ); + } + child = child.nextSibling(); + } + + if ( label.length() + stockItem.length() == 0 ) { + emitAtom( TQString("separator") ); + } else { + if ( name.isEmpty() ) + name = TQString( "action%1" ).arg( uniqueAction++ ); + emitAtom( TQString("action"), attribute(TQString("name"), name) ); + + if ( !activateHandler.isEmpty() ) { + TQString slot = activateHandler + TQString( "()" ); + GladeConnection c; + c.sender = name; + c.signal = TQString( "activated()" ); + c.slot = slot; + yyConnections.push_back( c ); + yySlots.insert( slot, TQString("public") ); + } + + TQString x; + GladeAction a; + + if ( gnomeuiinfoMenuXItem.exactMatch(stockItem) ) { + x = gnomeuiinfoMenuXItem.cap( 1 ); + a.menuText = yyStockMap[x]; + if ( x == TQString("EXIT") && qtAccel == 0 ) + qtAccel = TQt::CTRL + TQt::Key_Q; + } else { + a.menuText = accelerate( label ); + } + a.text = nonMenuText( a.menuText ); + a.toolTip = tooltip; + a.accel = qtAccel; + a.iconSet = icon; + yyActions.insert( name, a ); + if ( !x.isEmpty() ) + yyStockItemActions.insert( x, name ); + } + } + n = n.nextSibling(); + } +} + +void Glade2Ui::emitGtkMenuBarChildWidgets( + const TQValueList<TQDomElement>& childWidgets ) +{ + TQRegExp gnomeuiinfoMenuXTree( TQString("GNOMEUIINFO_MENU_(.+)_TREE") ); + + emitOpening( TQString("menubar") ); + emitProperty( TQString("name"), + TQString("MenuBar%1").arg(uniqueMenuBar++).latin1() ); + + TQValueList<TQDomElement>::ConstIterator c = childWidgets.begin(); + while ( c != childWidgets.end() ) { + TQValueList<TQDomElement> grandchildWidgets; + TQString gtkClass; + TQString label; + TQString name; + TQString stockItem; + + TQDomNode n = (*c).firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("class") ) { + gtkClass = getTextValue( n ); + } else if ( tagName == TQString("label") ) { + label = getTextValue( n ); + } else if ( tagName == TQString("name") ) { + name = getTextValue( n ); + } else if ( tagName == TQString("stock_item") ) { + stockItem = getTextValue( n ); + } else if ( tagName == TQString("widget") ) { + grandchildWidgets.push_back( n.toElement() ); + } + n = n.nextSibling(); + } + + if ( gtkClass == TQString("GtkMenuItem") && + grandchildWidgets.count() == 1 ) { + TQString text; + if ( gnomeuiinfoMenuXTree.exactMatch(stockItem) ) { + text = gnomeuiinfoMenuXTree.cap( 1 ); + if ( text == TQString("Files") ) + text = TQString( "Fi&les" ); + else + text = TQChar( '&' ) + text.left( 1 ) + + text.mid( 1 ).lower(); + } else { + text = accelerate( label ); + } + + AttributeMap attr; + attr.insert( TQString("name"), name ); + attr.insert( TQString("text"), text ); + + emitOpening( TQString("item"), attr ); + emitGtkMenu( grandchildWidgets.first() ); + emitClosing( TQString("item") ); + } + ++c; + } + emitClosing( TQString("menubar") ); +} + +void Glade2Ui::emitGtkToolbarChildWidgets( + const TQValueList<TQDomElement>& childWidgets ) +{ + TQRegExp gnomeStockPixmapX( TQString("GNOME_STOCK_PIXMAP_(.+)") ); + + emitOpening( TQString("toolbar"), attribute(TQString("dock"), TQString("2")) ); + emitProperty( TQString("name"), + TQString("ToolBar%1").arg(uniqueToolBar++).latin1() ); + + TQValueList<TQDomElement>::ConstIterator c = childWidgets.begin(); + while ( c != childWidgets.end() ) { + TQString childName; + TQString icon; + TQString label; + TQString name; + TQString stockPixmap; + TQString tooltip; + + TQDomNode n = (*c).firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("child_name") ) { + childName = getTextValue( n ); + } else if ( tagName == TQString("icon") ) { + icon = getTextValue( n ); + } else if ( tagName == TQString("label") ) { + label = getTextValue( n ); + } else if ( tagName == TQString("name") ) { + name = getTextValue( n ); + } else if ( tagName == TQString("stock_pixmap") ) { + stockPixmap = getTextValue( n ); + } else if ( tagName == TQString("tooltip") ) { + tooltip = getTextValue( n ); + } + n = n.nextSibling(); + } + + if ( childName == TQString("Toolbar:button") ) { + TQString actionName; + GladeAction a; + a.menuText = label; + a.text = label; + a.accel = 0; + a.iconSet = icon; + + if ( gnomeStockPixmapX.exactMatch(stockPixmap) ) { + TQString x = gnomeStockPixmapX.cap( 1 ); + actionName = yyStockItemActions[x]; + } + if ( actionName.isEmpty() ) { + if ( name.isEmpty() ) + actionName = TQString( "action%1" ).arg( uniqueAction++ ); + else + actionName = TQString( "action_%1" ).arg( name ); + yyActions.insert( actionName, a ); + } + if ( !tooltip.isEmpty() ) + yyActions[actionName].toolTip = tooltip; + + emitAtom( TQString("action"), attribute(TQString("name"), + actionName) ); + } else { + emitAtom( TQString("separator") ); + } + ++c; + } + emitClosing( TQString("toolbar") ); +} + +void Glade2Ui::emitPushButton( const TQString& text, const TQString& name ) +{ + emitOpening( TQString("widget"), + attribute(TQString("class"), TQString("TQPushButton")) ); + emitProperty( TQString("name"), name.latin1() ); + emitProperty( TQString("text"), text ); + if ( name.contains(TQString("ok")) > 0 ) { + emitProperty( TQString("default"), TQVariant(TRUE, 0) ); + } else if ( name.contains(TQString("help")) > 0 ) { + emitProperty( TQString("accel"), (int) TQt::Key_F1 ); + } + emitClosing( TQString("widget") ); +} + +void Glade2Ui::attach( AttributeMap *attr, int leftAttach, int rightAttach, + int topAttach, int bottomAttach ) +{ + if ( leftAttach >= 0 ) { + attr->insert( TQString("row"), TQString::number(topAttach) ); + attr->insert( TQString("column"), TQString::number(leftAttach) ); + if ( bottomAttach - topAttach != 1 ) + attr->insert( TQString("rowspan"), + TQString::number(bottomAttach - topAttach) ); + if ( rightAttach - leftAttach != 1 ) + attr->insert( TQString("colspan"), + TQString::number(rightAttach - leftAttach) ); + } +} + +void Glade2Ui::emitSpacer( const TQString& orientation, int leftAttach, + int rightAttach, int topAttach, int bottomAttach ) +{ + AttributeMap attr; + attach( &attr, leftAttach, rightAttach, topAttach, bottomAttach ); + emitOpening( TQString("spacer"), attr ); + emitProperty( TQString("name"), + TQString("Spacer%1").arg(uniqueSpacer++).latin1() ); + emitProperty( TQString("orientation"), orientation, TQString("enum") ); + emitProperty( TQString("sizeType"), TQString("Expanding"), + TQString("enum") ); + emitClosing( TQString("spacer") ); +} + +void Glade2Ui::emitPixmap( const TQString& imageName, int leftAttach, + int rightAttach, int topAttach, int bottomAttach ) +{ + emitOpeningWidget( TQString("TQLabel"), leftAttach, rightAttach, topAttach, + bottomAttach ); + emitProperty( TQString("sizePolicy"), + TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed) ); + emitProperty( TQString("pixmap"), imageName, TQString("pixmap") ); + emitClosing( TQString("widget") ); +} + +void Glade2Ui::emitGnomeAbout( TQString copyright, TQString authors, + TQString comments ) +{ + TQString prog = yyProgramName; + if ( prog.isEmpty() ) + prog = TQString( "Gnomovision 1.69" ); + if ( copyright.isEmpty() ) + copyright = TQString( "(C) 2001 Jasmin Blanchette" ); + if ( authors.isEmpty() ) + authors = TQString( "Jasmin Blanchette <jasmin@troll.no>" ); + if ( comments.isEmpty() ) + comments = TQString( "Gnomovision is the official GNU application." ); + + emitOpening( TQString("hbox") ); + emitSpacer( TQString("Horizontal") ); + emitOpeningWidget( TQString("TQLayoutWidget") ); + emitOpening( TQString("vbox") ); + emitProperty( TQString("spacing"), 17 ); + + /* + Emit the application name. + */ + emitOpeningWidget( TQString("TQLabel") ); + emitFontProperty( TQString("font"), 24, TRUE ); + emitProperty( TQString("text"), prog ); + emitProperty( TQString("alignment"), TQString("AlignAuto|AlignCenter"), + TQString("set") ); + emitClosing( TQString("widget") ); + + /* + Emit the copyright notice. + */ + emitOpeningWidget( TQString("TQLabel") ); + emitFontProperty( TQString("font"), 12, TRUE ); + emitProperty( TQString("text"), copyright ); + emitClosing( TQString("widget") ); + + /* + Emit the authors' names. + */ + emitOpeningWidget( TQString("TQLayoutWidget") ); + emitOpening( TQString("hbox") ); + + emitOpeningWidget( TQString("TQLabel") ); + emitFontProperty( TQString("font"), 12, TRUE ); + emitProperty( TQString("text"), TQString("Authors:") ); + emitProperty( TQString("alignment"), TQString("AlignAuto|AlignTop"), + TQString("set") ); + emitClosing( TQString("widget") ); + + emitOpeningWidget( TQString("TQLabel") ); + emitFontProperty( TQString("font"), 12, FALSE ); + emitProperty( TQString("text"), authors ); + emitProperty( TQString("alignment"), TQString("AlignAuto|AlignTop"), + TQString("set") ); + emitClosing( TQString("widget") ); + + emitSpacer( TQString("Horizontal") ); + + emitClosing( TQString("hbox") ); + emitClosing( TQString("widget") ); + + /* + Emit the comments. + */ + emitOpeningWidget( TQString("TQLabel") ); + emitFontProperty( TQString("font"), 10, FALSE ); + emitProperty( TQString("text"), comments ); + emitProperty( TQString("alignment"), TQString("AlignAuto|AlignTop"), + TQString("set") ); + emitClosing( TQString("widget") ); + + /* + Emit the spacer and the OK button. + */ + emitSpacer( TQString("Vertical") ); + + emitOpeningWidget( TQString("TQLayoutWidget") ); + emitOpening( TQString("hbox") ); + emitSpacer( TQString("Horizontal") ); + + emitPushButton( TQString("&OK"), TQString("okButton") ); + + emitSpacer( TQString("Horizontal") ); + emitClosing( TQString("hbox") ); + emitClosing( TQString("widget") ); + + emitClosing( TQString("vbox") ); + emitClosing( TQString("widget") ); + emitSpacer( TQString("Horizontal") ); + emitClosing( TQString("hbox") ); +} + +/* + GnomeApps are emitted in two passes, because some information goes + into the <widget> section, whereas other information goes into the + <toolbars> section. +*/ +void Glade2Ui::emitGnomeAppChildWidgetsPass1( + const TQValueList<TQDomElement>& childWidgets ) +{ + TQValueList<TQDomElement>::ConstIterator c = childWidgets.begin(); + while ( c != childWidgets.end() ) { + TQValueList<TQDomElement> grandchildWidgets; + TQString childName; + + TQDomNode n = (*c).firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("child_name") ) { + childName = getTextValue( n ); + } else if ( tagName == TQString("widget") ) { + grandchildWidgets.push_back( n.toElement() ); + } + n = n.nextSibling(); + } + + if ( childName == TQString("GnomeDock:contents") ) { + emitWidget( *c, FALSE ); + } else { + emitGnomeAppChildWidgetsPass1( grandchildWidgets ); + } + ++c; + } +} + +void Glade2Ui::doPass2( const TQValueList<TQDomElement>& childWidgets, + TQValueList<TQDomElement> *menuBar, + TQValueList<TQValueList<TQDomElement> > *toolBars ) +{ + TQValueList<TQDomElement>::ConstIterator c = childWidgets.begin(); + while ( c != childWidgets.end() ) { + TQValueList<TQDomElement> grandchildWidgets; + TQString childName; + TQString gtkClass; + + TQDomNode n = (*c).firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("child_name") ) { + childName = getTextValue( n ); + } else if ( tagName == TQString("class") ) { + gtkClass = getTextValue( n ); + } else if ( tagName == TQString("widget") ) { + grandchildWidgets.push_back( n.toElement() ); + } + n = n.nextSibling(); + } + + if ( gtkClass == TQString("GtkMenuBar") ) { + *menuBar = grandchildWidgets; + } else if ( gtkClass == TQString("GtkToolbar") ) { + toolBars->push_back( grandchildWidgets ); + } else if ( childName != TQString("GnomeDock:contents") ) { + doPass2( grandchildWidgets, menuBar, toolBars ); + } + ++c; + } +} + +void Glade2Ui::emitGnomeAppChildWidgetsPass2( + const TQValueList<TQDomElement>& childWidgets ) +{ + TQValueList<TQDomElement> menuBar; + TQValueList<TQValueList<TQDomElement> > toolBars; + + doPass2( childWidgets, &menuBar, &toolBars ); + + emitGtkMenuBarChildWidgets( menuBar ); + if ( !toolBars.isEmpty() ) { + emitOpening( TQString("toolbars") ); + while ( !toolBars.isEmpty() ) { + emitGtkToolbarChildWidgets( toolBars.first() ); + toolBars.remove( toolBars.begin() ); + } + emitClosing( TQString("toolbars") ); + } +} + +void Glade2Ui::emitGtkButtonChildWidgets( TQValueList<TQDomElement> childWidgets ) +{ + TQValueList<TQDomElement>::ConstIterator c = childWidgets.begin(); + while ( c != childWidgets.end() ) { + TQString label; + + TQDomNode n = (*c).firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("label") ) { + label = getTextValue( n ); + } else if ( tagName == TQString("widget") ) { + childWidgets.push_back( n.toElement() ); + } + n = n.nextSibling(); + } + + if ( !label.isEmpty() ) { + emitProperty( TQString("text"), accelerate(label) ); + break; + } + ++c; + } +} + +void Glade2Ui::emitGtkComboChildWidgets( + const TQValueList<TQDomElement>& childWidgets, const TQStringList& items ) +{ + TQString text; + + // there should be exactly one child, of type GtkEntry + if ( childWidgets.count() == 1 ) { + TQDomNode n = childWidgets.first().firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("name") ) { + // grep 'elsewhere' + emitProperty( TQString("name"), + fixedName(getTextValue(n).latin1()) ); + } else if ( tagName == TQString("text") ) { + text = getTextValue( n ); + } + n = n.nextSibling(); + } + } + + int n = 0; + TQStringList::ConstIterator s = items.begin(); + while ( s != items.end() ) { + if ( !text.isEmpty() && *s == text ) + emitProperty( TQString("currentItem"), n ); + n++; + ++s; + } + +} + +void Glade2Ui::emitGtkNotebookChildWidgets( + const TQValueList<TQDomElement>& childWidgets ) +{ + TQStringList tabNames; + TQStringList tabLabels; + + for ( int i = 0; i < (int) childWidgets.count(); i++ ) { + tabNames.push_back( TQString("tab%1").arg(i + 1) ); + tabLabels.push_back( TQString("Tab %1").arg(i + 1) ); + } + + TQValueList<TQDomElement>::ConstIterator c; + c = childWidgets.begin(); + + TQStringList::Iterator nam = tabNames.begin(); + TQStringList::Iterator lab = tabLabels.begin(); + + while ( c != childWidgets.end() ) { + TQString childName; + TQString name; + TQString label; + + TQDomNode n = (*c).firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("child_name") ) { + childName = getTextValue( n ); + } else if ( tagName == TQString("name") ) { + name = getTextValue( n ); + } else if ( tagName == TQString("label") ) { + label = getTextValue( n ); + } + n = n.nextSibling(); + } + + if ( childName == TQString("Notebook:tab") ) { + if ( !name.isEmpty() ) + *nam = name; + if ( !label.isEmpty() ) + *lab = label; + ++nam; + ++lab; + } + ++c; + } + + c = childWidgets.begin(); + while ( c != childWidgets.end() ) { + TQString childName; + TQString name; + TQString label; + + TQDomNode n = (*c).firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("child_name") ) + childName = getTextValue( n ); + n = n.nextSibling(); + } + + if ( childName != TQString("Notebook:tab") ) { + emitOpeningWidget( TQString("TQWidget") ); + emitProperty( TQString("name"), tabNames.first().latin1() ); + tabNames.remove( tabNames.begin() ); + emitAttribute( TQString("title"), accelerate(tabLabels.first()) ); + tabLabels.remove( tabLabels.begin() ); + emitWidget( *c, FALSE ); + emitClosing( TQString("widget") ); + } + ++c; + } +} + +void Glade2Ui::emitTQListViewColumns( const TQDomElement& qlistview ) +{ + TQDomNode n = qlistview.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("widget") ) { + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + TQString tagName = child.toElement().tagName(); + if ( tagName == TQString("label") ) { + emitOpening( TQString("column") ); + emitProperty( TQString("text"), + decelerate(getTextValue(child)) ); + emitClosing( TQString("column") ); + } + child = child.nextSibling(); + } + } else if ( tagName == TQString("class") ) { + TQString gtkClass = getTextValue( n ); + if ( gtkClass.endsWith(TQString("Tree")) ) + emitProperty( TQString("rootIsDecorated"), TQVariant(TRUE, 0) ); + } else if ( tagName == TQString("selection_mode") ) { + emitProperty( TQString("selectionMode"), + gtk2qtSelectionMode(getTextValue(n)) ); + } + n = n.nextSibling(); + } +} + +void Glade2Ui::emitGtkScrolledWindowChildWidgets( + const TQValueList<TQDomElement>& childWidgets, const TQString& qtClass ) +{ + if ( childWidgets.count() == 1 ) { + if ( qtClass == TQString("TQIconView") || + qtClass == TQString("TQListBox") || + qtClass == TQString("TQListView") ) { + TQDomNode n = childWidgets.first().firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("selection_mode") ) { + emitProperty( TQString("selectionMode"), + gtk2qtSelectionMode(getTextValue(n)) ); + } + n = n.nextSibling(); + } + } + + if ( qtClass == TQString("TQListView") ) { + emitTQListViewColumns( childWidgets.first() ); + } else if ( qtClass == TQString("TQTextEdit") || + qtClass == TQString("TQTextView") ) { + TQDomNode n = childWidgets.first().firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("text") ) + emitProperty( TQString("text"), getTextValue(n) ); + n = n.nextSibling(); + } + } + } +} + +void Glade2Ui::emitGnomeDruidPage( const TQDomElement& druidPage ) +{ + TQValueList<TQDomElement> childWidgets; + TQString gtkClass; + TQString logoImage; + TQString name; + TQString text; + TQString title; + TQString watermarkImage; + + emitOpeningWidget( TQString("TQWidget") ); + + TQDomNode n = druidPage.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("class") ) { + gtkClass = getTextValue( n ); + } else if ( tagName == TQString("logo_image") ) { + logoImage = getTextValue( n ); + } else if ( tagName == TQString("name") ) { + name = getTextValue( n ); + } else if ( tagName == TQString("text") ) { + text = getTextValue( n ); + } else if ( tagName == TQString("title") ) { + title = getTextValue( n ); + } else if ( tagName == TQString("watermark_image") ) { + watermarkImage = getTextValue( n ); + } else if ( tagName == TQString("widget") ) { + childWidgets.push_back( n.toElement() ); + } + n = n.nextSibling(); + } + + if ( !name.isEmpty() ) + emitProperty( TQString("name"), fixedName(name).latin1() ); + if ( title.isEmpty() ) + title = TQString( "Page" ); + emitAttribute( TQString("title"), title ); + + /* + We're striving to get the logoImage and/or the watermarkImage at + the right places with a grid layout. + */ + int leftAttach = 0; + int rightAttach = 0; + int topAttach = 0; + int bottomAttach = 0; + + int numImages = 0; + if ( !logoImage.isEmpty() ) { + topAttach = 1; + numImages++; + } + if ( !watermarkImage.isEmpty() ) { + leftAttach = 1; + numImages++; + } + rightAttach = leftAttach + numImages; + bottomAttach = topAttach + numImages; + + bool layouted = ( numImages > 0 ); + if ( layouted ) { + emitOpening( TQString("grid") ); + if ( !logoImage.isEmpty() ) + emitPixmap( imageName(logoImage), numImages, numImages + 1, 0, 1 ); + if ( !watermarkImage.isEmpty() ) + emitPixmap( imageName(watermarkImage), 0, 1, numImages, + numImages + 1 ); + } else { + leftAttach = -1; + rightAttach = -1; + topAttach = -1; + bottomAttach = -1; + } + + if ( gtkClass.endsWith(TQString("Standard")) ) { + emitChildWidgets( childWidgets, layouted, leftAttach, rightAttach, + topAttach, bottomAttach ); + } else if ( !text.isEmpty() ) { + if ( layouted ) + emitOpeningWidget( TQString("TQLayoutWidget"), leftAttach, + rightAttach, topAttach, bottomAttach ); + emitOpening( TQString("hbox") ); + emitSpacer( TQString("Horizontal") ); + emitOpeningWidget( TQString("TQLabel") ); + emitProperty( TQString("text"), text ); + emitClosing( TQString("widget") ); + emitSpacer( TQString("Horizontal") ); + emitClosing( TQString("hbox") ); + if ( layouted ) + emitClosing( TQString("widget") ); + } + + if ( layouted ) + emitClosing( TQString("grid") ); + emitClosing( TQString("widget") ); +} + +void Glade2Ui::emitGtkWindowChildWidgets( + const TQValueList<TQDomElement>& childWidgets, const TQString& qtClass ) +{ + if ( childWidgets.count() == 1 && qtClass == TQString("TQWizard") ) { + emitFontProperty( TQString("titleFont"), 18, FALSE ); + + TQDomNode n = childWidgets.first().firstChild(); + while ( !n.isNull() ) { + if ( n.toElement().tagName() == TQString("widget") ) + emitGnomeDruidPage( n.toElement() ); + n = n.nextSibling(); + } + } else { + emitChildWidgets( childWidgets, FALSE ); + } +} + +bool Glade2Ui::packEnd( const TQDomElement& widget ) +{ + TQDomNode n = widget.firstChild(); + while ( !n.isNull() ) { + if ( n.toElement().tagName() == TQString("child") ) { + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + if ( child.toElement().tagName() == TQString("pack") ) { + TQString pack = getTextValue( child ); + return pack.endsWith( TQString("_END") ); + } + child = child.nextSibling(); + } + } + n = n.nextSibling(); + } + return FALSE; +} + +void Glade2Ui::emitChildWidgets( const TQValueList<TQDomElement>& childWidgets, + bool layouted, int leftAttach, int rightAttach, + int topAttach, int bottomAttach ) +{ + TQValueList<TQDomElement> start; + TQValueList<TQDomElement> end; + TQValueList<TQDomElement>::ConstIterator e; + + if ( layouted ) { + e = childWidgets.begin(); + while ( e != childWidgets.end() ) { + if ( packEnd(*e) ) + end.push_front( *e ); + else + start.push_back( *e ); + ++e; + } + } else { + start = childWidgets; + } + + e = start.begin(); + while ( e != start.end() ) { + emitWidget( *e, layouted, leftAttach, rightAttach, topAttach, + bottomAttach ); + ++e; + } + e = end.begin(); + while ( e != end.end() ) { + emitWidget( *e, layouted, leftAttach, rightAttach, topAttach, + bottomAttach ); + ++e; + } +} + +void Glade2Ui::emitOpeningWidget( const TQString& qtClass, int leftAttach, + int rightAttach, int topAttach, + int bottomAttach ) +{ + AttributeMap attr = attribute( TQString("class"), qtClass ); + attach( &attr, leftAttach, rightAttach, topAttach, bottomAttach ); + emitOpening( TQString("widget"), attr ); +} + +/* + Returns TRUE if the vbox containing childWidgets should have a + spacer at the end to prevent it from looking bad, otherwise returns + FALSE. + + The algorithm is very experimental. +*/ +bool Glade2Ui::shouldPullup( const TQValueList<TQDomElement>& childWidgets ) +{ + TQRegExp gtkSmallWidget( TQString( + "G.*(?:Button|Combo|Dial|Entry|Label|OptionMenu|Picker|ProgressBar" + "|Separator|Statusbar|Toolbar|VBox)") ); + + TQValueList<TQDomElement>::ConstIterator c = childWidgets.begin(); + while ( c != childWidgets.end() ) { + TQValueList<TQDomElement> grandchildWidgets; + TQString gtkClass; + + TQDomNode n = (*c).firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( tagName == TQString("class") ) { + gtkClass = getTextValue( n ); + } else if ( tagName == TQString("widget") ) { + grandchildWidgets.push_back( n.toElement() ); + } + n = n.nextSibling(); + } + + if ( !gtkSmallWidget.exactMatch(gtkClass) || + !shouldPullup(grandchildWidgets) ) + return FALSE; + ++c; + } + return TRUE; +} + +TQString Glade2Ui::emitWidget( const TQDomElement& widget, bool layouted, + int leftAttach, int rightAttach, int topAttach, + int bottomAttach ) +{ + TQRegExp gtkLayoutWidget( TQString( + "Gtk(?:Packer|Table|Toolbar|[HV](?:(?:Button)?Box))") ); + TQRegExp gtkOrientedWidget( TQString( + "Gtk([HV])(?:Paned|Scale|Scrollbar|Separator)") ); + + TQValueList<TQDomElement> childWidgets; + TQString gtkClass; + TQString name; + TQString title; + int x = 0; + int y = 0; + int width = 0; + int height = 0; + int numRows = 0; + int numColumns = 0; + + bool active = FALSE; + TQString authors; + TQString childName; + TQString comments; + TQString copyright; + TQString creationFunction; + bool editable = TRUE; + TQString filename; + TQString focusTarget; + TQString hscrollbarPolicy; + TQString icon; + int initialChoice = 0; + TQStringList items; + TQString justify; + TQString label; + TQString logoImage; + int lower = -123456789; + int page = 10; + int pageSize = 10; + TQString selectionMode; + TQString shadowType( "GTK_SHADOW_NONE" ); + bool showText = TRUE; + bool showTitles = TRUE; + int step = 1; + TQString tabPos; + TQString text; + int textMaxLength = 0; + bool textVisible = TRUE; + TQString tooltip; + TQString type; + int upper = 123456789; + int value = 123456789; + bool valueInList = TRUE; + TQString vscrollbarPolicy; + TQString watermarkImage; + bool wrap = FALSE; + + bool topLevel = yyFormName.isEmpty(); + if ( topLevel ) + name = TQString( "Form%1" ).arg( uniqueForm++ ); + + TQDomNode n = widget.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + if ( !tagName.isEmpty() ) { + /* + Recognize the properties and stores them in variables. + This step is a bit silly, and if this function were to + be rewritten, almost everything would just be stored, as + strings, in a giant map, and looked up for when emitting + the properties. + */ + switch ( (uchar) tagName[0].cell() ) { + case 'a': + if ( tagName == TQString("active") ) { + active = isTrue( getTextValue(n) ); + } else if ( tagName == TQString("authors") ) { + authors = getTextValue( n ); + } + break; + case 'c': + if ( tagName == TQString("child") ) { + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + TQString childTagName = child.toElement().tagName(); + if ( childTagName == TQString("left_attach") ) { + leftAttach = getTextValue( child ).toInt(); + } else if ( childTagName == TQString("right_attach") ) { + rightAttach = getTextValue( child ).toInt(); + } else if ( childTagName == TQString("top_attach") ) { + topAttach = getTextValue( child ).toInt(); + } else if ( childTagName == TQString("bottom_attach") ) { + bottomAttach = getTextValue( child ).toInt(); + } + child = child.nextSibling(); + } + } else if ( tagName == TQString("child_name") ) { + childName = getTextValue( n ); + } else if ( tagName == TQString("class") ) { + gtkClass = getTextValue( n ); + } else if ( tagName == TQString("climb_rate") ) { + step = getTextValue( n ).toInt(); + } else if ( tagName == TQString("columns") ) { + numColumns = getTextValue( n ).toInt(); + } else if ( tagName == TQString("comments") ) { + comments = getTextValue( n ); + } else if ( tagName == TQString("copyright") ) { + copyright = getTextValue( n ); + } else if ( tagName == TQString("creation_function") ) { + creationFunction = getTextValue( n ); + } + break; + case 'd': + if ( tagName == TQString("default_focus_target") ) { + if ( focusTarget.isEmpty() ) + focusTarget = getTextValue( n ); + } + break; + case 'e': + if ( tagName == TQString("editable") ) + editable = isTrue( getTextValue(n) ); + break; + case 'f': + if ( tagName == TQString("filename") ) { + filename = getTextValue( n ); + } else if ( tagName == TQString("focus_target") ) { + focusTarget = getTextValue( n ); + } + break; + case 'h': + if ( tagName == TQString("height") ) { + height = getTextValue( n ).toInt(); + } else if ( tagName == TQString("hscrollbar_policy") ) { + hscrollbarPolicy = getTextValue( n ); + } + break; + case 'i': + if ( tagName == TQString("icon") ) { + icon = getTextValue( n ); + } else if ( tagName == TQString("initial_choice") ) { + initialChoice = getTextValue( n ).toInt(); + } else if ( tagName == TQString("items") ) { + items = TQStringList::split( TQChar('\n'), getTextValue(n) ); + } + break; + case 'j': + if ( tagName == TQString("justify") ) + justify = getTextValue( n ); + break; + case 'l': + if ( tagName == TQString("label") ) { + label = getTextValue( n ); + } else if ( tagName == TQString("logo_image") ) { + logoImage = getTextValue( n ); + } else if ( tagName == TQString("lower") ) { + lower = getTextValue( n ).toInt(); + } + break; + case 'n': + if ( tagName == TQString("name") ) + name = getTextValue( n ); + break; + case 'p': + if ( tagName == TQString("page") ) { + page = getTextValue( n ).toInt(); + } else if ( tagName == TQString("page_size") ) { + pageSize = getTextValue( n ).toInt(); + } + break; + case 'r': + if ( tagName == TQString("rows") ) + numRows = getTextValue( n ).toInt(); + break; + case 's': + if ( tagName == TQString("selection_mode") ) { + selectionMode = getTextValue( n ); + } else if ( tagName == TQString("shadow_type") ) { + shadowType = getTextValue( n ); + } else if ( tagName == TQString("show_text") ) { + showText = isTrue( getTextValue(n) ); + } else if ( tagName == TQString(TQString("show_titles")) ) { + showTitles = isTrue( getTextValue(n) ); + } else if ( tagName == TQString("step") ) { + step = getTextValue( n ).toInt(); + } else if ( tagName == TQString("stock_button") ) { + /* + Let's cheat: We convert the symbolic name into a + button label. + */ + label = getTextValue( n ); + int k = label.findRev( TQChar('_') ); + if ( k != -1 ) + label = label.mid( k + 1 ); + if ( !label.isEmpty() && label != TQString("OK") ) + label = label.left( 1 ) + label.mid( 1 ).lower(); + } + break; + case 't': + if ( tagName == TQString("tab_pos") ) { + tabPos = getTextValue( n ); + } else if ( tagName == TQString("text") ) { + text = getTextValue( n ); + } else if ( tagName == TQString("textMaxLength") ) { + textMaxLength = getTextValue( n ).toInt(); + } else if ( tagName == TQString("textVisible") ) { + textVisible = isTrue( getTextValue(n) ); + } else if ( tagName == TQString("title") ) { + title = getTextValue( n ); + } else if ( tagName == TQString("tooltip") ) { + tooltip = getTextValue( n ); + } else if ( tagName == TQString("type") ) { + type = getTextValue( n ); + } + break; + case 'u': + if ( tagName == TQString("upper") ) + upper = getTextValue( n ).toInt(); + break; + case 'v': + if ( tagName == TQString("value") ) { + value = getTextValue( n ).toInt(); + } else if ( tagName == TQString("value_in_list") ) { + valueInList = isTrue( getTextValue(n) ); + } else if ( tagName == TQString("vscrollbar_policy") ) { + vscrollbarPolicy = getTextValue( n ); + } + break; + case 'w': + if ( tagName == TQString("watermark_image") ) { + watermarkImage = getTextValue( n ); + } else if ( tagName == TQString("widget") ) + childWidgets.push_back( n.toElement() ); + else if ( tagName == TQString("width") ) + width = getTextValue( n ).toInt(); + else if ( tagName == TQString("wrap") ) + wrap = isTrue( getTextValue(n) ); + break; + case 'x': + if ( tagName == TQString("x") ) + x = getTextValue( n ).toInt(); + break; + case 'y': + if ( tagName == TQString("y") ) + y = getTextValue( n ).toInt(); + } + } + n = n.nextSibling(); + } + + if ( topLevel ) { + yyFormName = name; + emitSimpleValue( TQString("class"), yyFormName ); + } + + if ( gtkLayoutWidget.exactMatch(gtkClass) ) { + TQString boxKind; + TQString orientation; + + if ( gtkClass.startsWith(TQString("GtkH")) || + gtkClass == TQString(TQString("GtkToolbar")) ) { + /* + GtkToolbar, right. Toolbars may appear anywhere in a + widget, but then they really are just a row of buttons. + */ + boxKind = TQString( "hbox" ); + orientation = TQString( "Horizontal" ); + } else if ( gtkClass.startsWith(TQString("GtkV")) || + gtkClass == TQString("GtkPacker") ) { + /* + We don't support the GtkPacker, whose trails lead to + destruction. + */ + boxKind = TQString( "vbox" ); + orientation = TQString( "Vertical" ); + } else { + boxKind = TQString( "grid" ); + } + + if ( layouted ) + emitOpeningWidget( TQString("TQLayoutWidget"), leftAttach, + rightAttach, topAttach, bottomAttach ); + emitOpening( boxKind ); + emitProperty( TQString("name"), fixedName(name).latin1() ); + if ( gtkClass == TQString("GtkHButtonBox") || + childName == TQString("Dialog:action_area") ) + emitSpacer( orientation ); + emitChildWidgets( childWidgets, TRUE ); + + if ( gtkClass == TQString("GtkVButtonBox") || + childName == TQString("Dialog:action_area") || + (boxKind == TQString("vbox") && shouldPullup(childWidgets)) ) { + emitSpacer( orientation ); + } else if ( boxKind == TQString("grid") && shouldPullup(childWidgets) ) { + emitSpacer( TQString("Vertical"), 0, numColumns, numRows, + numRows + 1 ); + } + + emitClosing( boxKind ); + if ( layouted ) + emitClosing( TQString("widget") ); + } else if ( gtkClass == TQString("GtkFixed") && !layouted ) { + emitChildWidgets( childWidgets, FALSE ); + /* + Placeholders in a grid are typically needless. + */ + } else if ( !(leftAttach >= 0 && gtkClass == TQString("Placeholder")) ) { + bool needFakeLayout = ( !layouted && !topLevel && x == 0 && y == 0 && + width == 0 && height == 0 ); + TQString qtClass = gtk2qtClass( gtkClass, childWidgets ); + bool unknown = FALSE; + + if ( qtClass == TQString("TQFrame") && !label.isEmpty() ) { + qtClass = TQString( "TQButtonGroup" ); + } else if ( qtClass == TQString("TQListView") && !showTitles && + gtkClass.endsWith(TQString("List")) ) { + qtClass = TQString( "TQListBox" ); + } else if ( qtClass == TQString("Custom") ) { + qtClass = creationFunction; + yyCustomWidgets.insert( qtClass, TQString::null ); + } else if ( qtClass == TQString("Unknown") ) { + qtClass = TQString( "TQLabel" ); + unknown = TRUE; + } + + if ( qtClass.isEmpty() ) { + emitChildWidgets( childWidgets, layouted, leftAttach, rightAttach, + topAttach, bottomAttach ); + } else { + if ( needFakeLayout ) { + emitOpening( TQString("vbox") ); + emitProperty( TQString("margin"), 11 ); + } + emitOpeningWidget( qtClass, leftAttach, rightAttach, topAttach, + bottomAttach ); + + // grep 'elsewhere' + if ( gtkClass != TQString("GtkCombo") ) + emitProperty( TQString("name"), fixedName(name).latin1() ); + if ( !title.isEmpty() ) + emitProperty( TQString("caption"), title ); + if ( !layouted && (x != 0 || y != 0 || width != 0 || height != 0) ) + emitProperty( TQString("geometry"), TQRect(x, y, width, height) ); + if ( gtkClass == TQString("GtkToggleButton") ) { + emitProperty( TQString("toggleButton"), TQVariant(TRUE, 0) ); + if ( active ) + emitProperty( TQString("on"), TQVariant(TRUE, 0) ); + } else { + if ( active ) + emitProperty( TQString("checked"), TQVariant(TRUE, 0) ); + } + + if ( !editable ) + emitProperty( TQString("readOnly"), TQVariant(TRUE, 0) ); + if ( !focusTarget.isEmpty() ) + emitProperty( TQString("buddy"), + fixedName(focusTarget).latin1() ); + if ( !hscrollbarPolicy.isEmpty() ) + emitProperty( TQString("hScrollBarMode"), + gtk2qtScrollBarMode(hscrollbarPolicy), + TQString("enum") ); + if ( !vscrollbarPolicy.isEmpty() ) + emitProperty( TQString("vScrollBarMode"), + gtk2qtScrollBarMode(vscrollbarPolicy), + TQString("enum") ); + if ( !justify.isEmpty() || + (wrap && gtkClass != TQString("GtkSpinButton")) ) { + TQStringList flags; + if ( wrap ) + flags.push_back( TQString("WordBreak") ); + + if ( justify.endsWith(TQString("_CENTER")) ) { + flags.push_back( TQString("AlignCenter") ); + } else { + if ( justify.endsWith(TQString("_RIGHT")) ) + flags.push_back( TQString("AlignRight") ); + flags.push_back( TQString("AlignVCenter") ); + } + + if ( !flags.isEmpty() ) + emitProperty( TQString("alignment"), flags.join(TQChar('|')), + TQString("set") ); + } + if ( !label.isEmpty() ) { + if ( gtkClass.endsWith(TQString("Frame")) ) { + emitProperty( TQString("title"), label ); + } else { + emitProperty( TQString("text"), accelerate(label) ); + } + } + if ( lower != -123456789 ) + emitProperty( TQString("minValue"), lower ); + if ( upper != 123456789 ) + emitProperty( TQString("maxValue"), upper ); + if ( value != 123456789 ) { + if ( gtkClass == TQString("GtkProgressBar") ) { + emitProperty( TQString("progress"), value ); + } else { + emitProperty( TQString("value"), value ); + } + } + if ( TQMAX(page, pageSize) != 10 && + gtkClass.endsWith(TQString("Scrollbar")) ) + emitProperty( TQString("pageStep"), TQMAX(page, pageSize) ); + if ( !selectionMode.isEmpty() ) + emitProperty( TQString("selectionMode"), + gtk2qtSelectionMode(selectionMode), + TQString("enum") ); + if ( !shadowType.endsWith(TQString("_NONE")) ) { + TQString shape = shadowType.contains( TQString("_ETCHED_") ) > 0 ? + TQString( "Box" ) : TQString( "WinPanel" ); + TQString shadow = shadowType.endsWith( TQString("_IN") ) ? + TQString( "Sunken" ) : TQString( "Raised" ); + emitProperty( TQString("frameShape"), shape, TQString("enum") ); + emitProperty( TQString("frameShadow"), shadow, TQString("enum") ); + } + if ( !showText ) + emitProperty( TQString("percentageVisible"), + TQVariant(FALSE, 0) ); + if ( step != 1 ) + emitProperty( TQString("lineStep"), step ); + if ( tabPos.endsWith(TQString("_BOTTOM")) || + tabPos.endsWith(TQString("_RIGHT")) ) + emitProperty( TQString("tabPosition"), TQString("Bottom") ); + if ( !text.isEmpty() ) + emitProperty( TQString("text"), text ); + if ( textMaxLength != 0 ) + emitProperty( TQString("maxLength"), textMaxLength ); + if ( !textVisible ) + emitProperty( TQString("echoMode"), TQString("Password"), + TQString("enum") ); + if ( !tooltip.isEmpty() ) + emitProperty( TQString("toolTip"), tooltip ); + if ( !valueInList ) + emitProperty( TQString("editable"), TQVariant(TRUE, 0) ); + if ( wrap && gtkClass == TQString("GtkSpinButton") ) + emitProperty( TQString("wrapping"), TQVariant(TRUE, 0) ); + + if ( gtkClass.endsWith(TQString("Tree")) ) { + emitProperty( TQString("rootIsDecorated"), TQVariant(TRUE, 0) ); + } else if ( gtkOrientedWidget.exactMatch(gtkClass) ) { + TQString s = ( gtkOrientedWidget.cap(1) == TQChar('H') ) ? + TQString( "Horizontal" ) : TQString( "Vertical" ); + emitProperty( TQString("orientation"), s, TQString("enum") ); + } + + if ( qtClass == TQString("TQListView") ) + emitProperty( TQString("resizeMode"), TQString("AllColumns"), + TQString("enum") ); + + while ( !items.isEmpty() ) { + emitOpening( TQString("item") ); + emitProperty( TQString("text"), items.first() ); + emitClosing( TQString("item") ); + items.remove( items.begin() ); + } + if ( initialChoice != 0 ) + emitProperty( TQString("currentItem"), initialChoice ); + + if ( !icon.isEmpty() ) + emitProperty( TQString("pixmap"), imageName(icon), + TQString("pixmap") ); + + if ( gtkClass == TQString("GnomeAbout") ) { + emitGnomeAbout( copyright, authors, comments ); + } else if ( gtkClass == TQString("GnomeApp") ) { + emitGnomeAppChildWidgetsPass1( childWidgets ); + } else if ( gtkClass == TQString("GnomePropertyBox") ) { + emitOpening( TQString("vbox") ); + emitChildWidgets( childWidgets, TRUE ); + emitOpeningWidget( TQString("TQLayoutWidget") ); + emitOpening( TQString("hbox") ); + emitPushButton( TQString("&Help"), TQString("helpButton") ); + emitSpacer( TQString("Horizontal") ); + emitPushButton( TQString("&OK"), TQString("okButton") ); + emitPushButton( TQString("&Apply"), TQString("applyButton") ); + emitPushButton( TQString("&Close"), TQString("closeButton") ); + emitClosing( TQString("hbox") ); + emitClosing( TQString("widget") ); + emitClosing( TQString("vbox") ); + } else if ( gtkClass.endsWith(TQString("Button")) ) { + if ( label.isEmpty() ) + emitGtkButtonChildWidgets( childWidgets ); + } else if ( gtkClass == TQString("GtkCombo") ) { + emitGtkComboChildWidgets( childWidgets, items ); + } else if ( gtkClass == TQString("GtkNotebook") ) { + emitGtkNotebookChildWidgets( childWidgets ); + } else if ( gtkClass == TQString("GtkWindow") ) { + emitGtkWindowChildWidgets( childWidgets, qtClass ); + } else if ( gtkClass == TQString("GtkScrolledWindow") ) { + emitGtkScrolledWindowChildWidgets( childWidgets, qtClass ); + } else if ( qtClass == TQString("TQListView") ) { + emitTQListViewColumns( widget ); + } else if ( unknown || gtkClass == TQString("Placeholder") ) { + TQString prefix; + if ( unknown ) + prefix = gtkClass; + emitProperty( TQString("text"), + TQString("<font color=\"red\">%1<b>?</b></font>") + .arg(prefix) ); + emitProperty( TQString("alignment"), + TQString("AlignAuto|AlignCenter"), + TQString("set") ); + } else if ( qtClass != TQString("TQListBox") ) { + emitChildWidgets( childWidgets, FALSE ); + } + + emitClosing( TQString("widget") ); + if ( needFakeLayout ) + emitClosing( TQString("vbox") ); + if ( gtkClass == TQString("GnomeApp") ) + emitGnomeAppChildWidgetsPass2( childWidgets ); + } + } + return name; +} + +TQStringList Glade2Ui::convertGladeFile( const TQString& fileName ) +{ + TQStringList outFileNames; + + yyFileName = fileName; + + TQDomDocument doc( TQString("GTK-Interface") ); + TQFile f( fileName ); + if ( !f.open(IO_ReadOnly) ) { + error( TQString("Cannot open file for reading.") ); + return TQStringList(); + } + if ( !doc.setContent(&f) ) { + error( TQString("File is not an XML file.") ); + f.close(); + return TQStringList(); + } + f.close(); + + TQDomElement root = doc.documentElement(); + if ( root.tagName() != TQString("GTK-Interface") ) { + error( TQString("File is not a Glade XML file.") ); + return TQStringList(); + } + + int widgetNo = 0; + int numWidgets = 0; + TQDomNode n = root.firstChild(); + while ( !n.isNull() ) { + if ( n.toElement().tagName() == TQString("widget") ) + numWidgets++; + n = n.nextSibling(); + } + + TQProgressDialog fremskritt( TQString("Converting Glade files..."), + TQString("Abort Conversion"), numWidgets, 0, + "fremskritt", TRUE ); + + n = root.firstChild(); + while ( !n.isNull() ) { + TQString tagName = n.toElement().tagName(); + + if ( tagName == TQString("project") ) { + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + TQString childTagName = child.toElement().tagName(); + if ( childTagName == TQString("pixmaps_directory") ) { + yyPixmapDirectory = getTextValue( child ); + } else if ( childTagName == TQString("program_name") ) { + yyProgramName = getTextValue( child ); + } + child = child.nextSibling(); + } + } else if ( tagName == TQString("widget") ) { + yyOut = TQString::null; + yyCustomWidgets.clear(); + yyStockItemActions.clear(); + yyActions.clear(); + yyConnections.clear(); + yySlots.clear(); + yyFormName = TQString::null; + yyImages.clear(); + + uniqueAction = 1; + uniqueForm = 1; + uniqueMenuBar = 1; + uniqueSpacer = 1; + uniqueToolBar = 1; + + emitHeader(); + TQString name = emitWidget( n.toElement(), FALSE ); + + if ( !yyCustomWidgets.isEmpty() ) { + emitOpening( TQString("customwidgets") ); + + TQMap<TQString, TQString>::Iterator c = yyCustomWidgets.begin(); + while ( c != yyCustomWidgets.end() ) { + emitOpening( TQString("customwidget") ); + emitSimpleValue( TQString("class"), c.key() ); + if ( !(*c).isEmpty() ) + emitSimpleValue( TQString("header"), *c, + attribute(TQString("location"), + TQString("local")) ); + emitClosing( TQString("customwidget") ); + ++c; + } + emitClosing( TQString("customwidgets") ); + } + + if ( !yyActions.isEmpty() ) { + emitOpening( TQString("actions") ); + + TQMap<TQString, GladeAction>::Iterator a = yyActions.begin(); + while ( a != yyActions.end() ) { + emitOpening( TQString("action") ); + emitProperty( TQString("name"), + fixedName(a.key()).latin1() ); + emitProperty( TQString("text"), (*a).text ); + emitProperty( TQString("menuText"), (*a).menuText ); + if ( (*a).toolTip ) + emitProperty( TQString("toolTip"), (*a).toolTip ); + if ( (*a).accel != 0 ) + emitProperty( TQString("accel"), (*a).accel ); + if ( !(*a).iconSet.isEmpty() ) + emitProperty( TQString("iconSet"), + imageName((*a).iconSet), + TQString("iconset") ); + emitClosing( TQString("action") ); + ++a; + } + emitClosing( TQString("actions") ); + } + + if ( !yyImages.isEmpty() ) { + uint maxLength = 524288; + char *data = new char[maxLength]; + + TQString dir = yyFileName; + dir.truncate( dir.findRev(TQChar('/')) + 1 ); + dir += yyPixmapDirectory; + + emitOpening( TQString("images") ); + + TQMap<TQString, TQString>::ConstIterator im = yyImages.begin(); + while ( im != yyImages.end() ) { + uint length = 0; + const char *format = 0; + + TQString fn = dir + TQChar( '/' ) + im.key(); + TQFile f( fn ); + if ( !f.open(IO_ReadOnly) ) { + error( TQString("Cannot open image '%1' for reading.") + .arg(fn) ); + } else { + length = f.readBlock( data, maxLength ); + f.at( 0 ); + format = TQImageIO::imageFormat( &f ); + f.close(); + } + if ( format == 0 ) + format = "XPM"; + + AttributeMap attr; + attr.insert( TQString("format"), TQString(format) ); + attr.insert( TQString("length"), TQString::number(length) ); + + emitOpening( TQString("image"), + attribute(TQString("name"), *im) ); + emitSimpleValue( TQString("data"), hexed(data, length), + attr ); + emitClosing( TQString("image") ); + ++im; + } + emitClosing( TQString("images") ); + delete[] data; + } + + if ( yyConnections.count() + yySlots.count() > 0 ) { + emitOpening( TQString("connections") ); + + TQValueList<GladeConnection>::Iterator c = yyConnections.begin(); + while ( c != yyConnections.end() ) { + emitOpening( TQString("connection") ); + emitSimpleValue( TQString("sender"), (*c).sender ); + emitSimpleValue( TQString("signal"), (*c).signal ); + emitSimpleValue( TQString("receiver"), yyFormName ); + emitSimpleValue( TQString("slot"), (*c).slot ); + emitClosing( TQString("connection") ); + ++c; + } + + TQMap<TQString, TQString>::Iterator s = yySlots.begin(); + while ( s != yySlots.end() ) { + AttributeMap attr; + attr.insert( TQString("access"), *s ); + attr.insert( TQString("language"), TQString("C++") ); + attr.insert( TQString("returntype"), TQString("void") ); + emitSimpleValue( TQString("slot"), s.key(), attr ); + ++s; + } + emitClosing( TQString("connections") ); + } + emitFooter(); + + TQString outFileName = fileName; + int k = outFileName.findRev( "." ); + if ( k != -1 ) + outFileName.truncate( k ); + if ( widgetNo != 0 ) + outFileName += TQString::number( widgetNo + 1 ); + outFileName += TQString( ".ui" ); + FILE *out = fopen( outFileName.latin1(), "w" ); + if ( out == 0 ) { + qWarning( "glade2ui: Could not open file '%s'", + outFileName.latin1() ); + } else { + if ( !yyOut.isEmpty() ) + fprintf( out, "%s", yyOut.latin1() ); + fclose( out ); + outFileNames.push_back( outFileName ); + } + yyOut = TQString::null; + widgetNo++; + + qApp->processEvents(); + if ( fremskritt.wasCancelled() ) + break; + fremskritt.setProgress( widgetNo ); + } + n = n.nextSibling(); + } + return outFileNames; +} diff --git a/tools/designer/plugins/glade/glade2ui.h b/tools/designer/plugins/glade/glade2ui.h new file mode 100644 index 000000000..f50a08fe6 --- /dev/null +++ b/tools/designer/plugins/glade/glade2ui.h @@ -0,0 +1,169 @@ +/********************************************************************** +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef GLADE2UI_H +#define GLADE2UI_H + +#include <qdom.h> +#include <qmap.h> +#include <qstring.h> +#include <qvariant.h> + +typedef TQMap<TQString, TQString> AttributeMap; + +struct GladeAction +{ + TQString text; + TQString menuText; + TQString toolTip; + int accel; + TQString iconSet; +}; + +struct GladeConnection +{ + TQString sender; + TQString signal; + TQString slot; +}; + +class Glade2Ui +{ +public: + Glade2Ui(); + + TQStringList convertGladeFile( const TQString& fileName ); + +private: + TQString imageName( const TQString& fileName ); + TQString opening( const TQString& tag, + const AttributeMap& attr = AttributeMap() ); + TQString closing( const TQString& tag ); + TQString atom( const TQString& tag, + const AttributeMap& attr = AttributeMap() ); + void error( const TQString& message ); + void syntaxError(); + TQString getTextValue( const TQDomNode& node ); + void emitHeader(); + void emitFooter(); + void emitSimpleValue( const TQString& tag, const TQString& value, + const AttributeMap& attr = AttributeMap() ); + void emitOpening( const TQString& tag, + const AttributeMap& attr = AttributeMap() ); + void emitClosing( const TQString& tag ); + void emitAtom( const TQString& tag, + const AttributeMap& attr = AttributeMap() ); + void emitVariant( const TQVariant& val, + const TQString& stringType = "string" ); + void emitProperty( const TQString& prop, const TQVariant& val, + const TQString& stringType = "string" ); + void emitFontProperty( const TQString& prop, int pointSize, bool bold ); + void emitAttribute( const TQString& prop, const TQVariant& val, + const TQString& stringType = "string" ); + TQString gtk2qtClass( const TQString& gtkClass, + const TQValueList<TQDomElement>& childWidgets ); + + int matchAccelOnActivate( const TQDomElement& accel ); + void emitGtkMenu( const TQDomElement& menu ); + void emitGtkMenuBarChildWidgets( + const TQValueList<TQDomElement>& childWidgets ); + void emitGtkToolbarChildWidgets( + const TQValueList<TQDomElement>& childWidgets ); + void emitPushButton( const TQString& text, const TQString& name ); + void attach( AttributeMap *attr, int leftAttach, int rightAttach, + int topAttach, int bottomAttach ); + void emitSpacer( const TQString& orientation, int leftAttach = -1, + int rightAttach = -1, int topAttach = -1, + int bottomAttach = -1 ); + void emitPixmap( const TQString& imageName, int leftAttach = -1, + int rightAttach = -1, int topAttach = -1, + int bottomAttach = -1 ); + void emitGnomeAbout( TQString copyright, TQString authors, TQString comments ); + void emitGnomeAppChildWidgetsPass1( + const TQValueList<TQDomElement>& childWidgets ); + void doPass2( const TQValueList<TQDomElement>& childWidgets, + TQValueList<TQDomElement> *menuBar, + TQValueList<TQValueList<TQDomElement> > *toolBars ); + void emitGnomeAppChildWidgetsPass2( + const TQValueList<TQDomElement>& childWidgets ); + void emitGtkButtonChildWidgets( TQValueList<TQDomElement> childWidgets ); + void emitGtkComboChildWidgets( const TQValueList<TQDomElement>& childWidgets, + const TQStringList& items ); + void emitGtkNotebookChildWidgets( + const TQValueList<TQDomElement>& childWidgets ); + void emitTQListViewColumns( const TQDomElement& qlistview ); + void emitGtkScrolledWindowChildWidgets( + const TQValueList<TQDomElement>& childWidgets, + const TQString& qtClass ); + void emitGnomeDruidPage( const TQDomElement& druidPage ); + void emitGtkWindowChildWidgets( const TQValueList<TQDomElement>& childWidgets, + const TQString& qtClass ); + bool packEnd( const TQDomElement& widget ); + void emitChildWidgets( const TQValueList<TQDomElement>& childWidgets, + bool layouted, int leftAttach = -1, + int rightAttach = -1, int topAttach = -1, + int bottomAttach = -1 ); + void emitOpeningWidget( const TQString& qtClass, int leftAttach = -1, + int rightAttach = -1, int topAttach = -1, + int bottomAttach = -1 ); + bool shouldPullup( const TQValueList<TQDomElement>& childWidgets ); + TQString emitWidget( const TQDomElement& widget, bool layouted, + int leftAttach = -1, int rightAttach = -1, + int topAttach = -1, int bottomAttach = -1 ); + + TQString yyOut; + TQString yyIndentStr; + TQString yyFileName; + TQString yyProgramName; + TQString yyPixmapDirectory; + TQMap<TQString, TQString> yyClassNameMap; + TQMap<TQString, TQString> yyStockMap; + TQMap<TQString, int> yyKeyMap; + TQMap<TQString, TQString> yyCustomWidgets; + TQMap<TQString, TQString> yyStockItemActions; + TQMap<TQString, GladeAction> yyActions; + TQValueList<GladeConnection> yyConnections; + TQMap<TQString, TQString> yySlots; + TQString yyFormName; + TQMap<TQString, TQString> yyImages; + + int numErrors; + int uniqueAction; + int uniqueForm; + int uniqueMenuBar; + int uniqueSpacer; + int uniqueToolBar; +}; + +#endif diff --git a/tools/designer/plugins/glade/main.cpp b/tools/designer/plugins/glade/main.cpp new file mode 100644 index 000000000..e1504e067 --- /dev/null +++ b/tools/designer/plugins/glade/main.cpp @@ -0,0 +1,109 @@ +/********************************************************************** +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include <filterinterface.h> +#include <qapplication.h> + +#include "glade2ui.h" + +class GladeFilter : public ImportFilterInterface, public TQLibraryInterface +{ +public: + GladeFilter(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface **iface ); + Q_REFCOUNT; + + TQStringList featureList() const; + TQStringList import( const TQString& filter, const TQString& filename ); + + bool init(); + void cleanup(); + bool canUnload() const; + +}; + +GladeFilter::GladeFilter() +{ +} + +TQRESULT GladeFilter::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)(ImportFilterInterface*)this; + else if ( uuid == IID_QFeatureList ) + *iface = (TQFeatureListInterface*)this; + else if ( uuid == IID_ImportFilter ) + *iface = (ImportFilterInterface*)this; + else if ( uuid == IID_QLibrary ) + *iface = (TQLibraryInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +TQStringList GladeFilter::featureList() const +{ + TQStringList list; + list << "Glade Files (*.glade)" ; + return list; +} + +TQStringList GladeFilter::import( const TQString &, const TQString& filename ) +{ + Glade2Ui g; + return g.convertGladeFile( filename ); +} + +bool GladeFilter::init() +{ + return TRUE; +} + +void GladeFilter::cleanup() +{ +} + +bool GladeFilter::canUnload() const +{ + return TRUE; +} + +Q_EXPORT_COMPONENT() +{ + Q_CREATE_INSTANCE( GladeFilter ) +} diff --git a/tools/designer/plugins/kdevdlg/kdevdlg.pro b/tools/designer/plugins/kdevdlg/kdevdlg.pro new file mode 100644 index 000000000..d90d646ab --- /dev/null +++ b/tools/designer/plugins/kdevdlg/kdevdlg.pro @@ -0,0 +1,11 @@ +TEMPLATE = lib +CONFIG += qt warn_on release plugin +HEADERS = kdevdlg2ui.h +SOURCES = main.cpp kdevdlg2ui.cpp +DESTDIR = ../../../../plugins/designer +TARGET = kdevdlgplugin +INCLUDEPATH += ../../interfaces + + +target.path += $$plugins.path/designer +INSTALLS += target diff --git a/tools/designer/plugins/kdevdlg/kdevdlg2ui.cpp b/tools/designer/plugins/kdevdlg/kdevdlg2ui.cpp new file mode 100644 index 000000000..5cd363d60 --- /dev/null +++ b/tools/designer/plugins/kdevdlg/kdevdlg2ui.cpp @@ -0,0 +1,524 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "kdevdlg2ui.h" +#include <qdir.h> +#include <qstring.h> +#include <qptrstack.h> + +/// some little helpers /// + +void KDEVDLG2UI::wi() +{ + for ( int i = 0; i < indentation; i++ ) + *out << " "; +} + +void KDEVDLG2UI::indent() +{ + indentation++; +} + +void KDEVDLG2UI::undent() +{ + indentation--; +} + +void KDEVDLG2UI::writeClass( const TQString& name ) +{ + wi(); *out << "<class>" << name << "</class>" << endl; +} + +void KDEVDLG2UI::writeWidgetStart( const TQString& qclass ) +{ + wi(); *out << "<widget class=\"" << qclass << "\">" << endl; +} + +void KDEVDLG2UI::writeWidgetEnd() +{ + wi(); *out << "</widget>" << endl; +} + +void KDEVDLG2UI::writeCString( const TQString& name, const TQString& value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<cstring>" << value << "</cstring>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeString( const TQString& name, const TQString& value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<string>" << value << "</string>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeRect( const TQString& name, int x, int y, int w, int h ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<rect>" << endl; indent(); + wi(); *out << "<x>" << x << "</x>" << endl; + wi(); *out << "<y>" << y << "</y>" << endl; + wi(); *out << "<width>" << w << "</width>" << endl; + wi(); *out << "<height>" << h << "</height>" << endl; undent(); + wi(); *out << "</rect>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeFont( const TQString& family, int pointsize ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>font</name>" << endl; + wi(); *out << "<font>" << endl; indent(); + wi(); *out << "<family>" << family << "</family>" << endl; + wi(); *out << "<pointsize>" << pointsize << "</pointsize>" << endl; undent(); + wi(); *out << "</font>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeBool( const TQString& name, bool value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<bool>" << (value ? "true" : "false") << "</bool>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeNumber( const TQString& name, int value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<number>" << value << "</number>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeEnum( const TQString& name, const TQString& value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<enum>" << value << "</enum>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeSet( const TQString& name, const TQString& value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<set>" << value << "</set>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeItem( const TQString& name, const TQString& value ) +{ + wi(); *out << "<item>" << endl; indent(); + writeString( name, value ); undent(); + wi(); *out << "</item>" << endl; +} + +void KDEVDLG2UI::writeColumn( const TQString& name, const TQString& value ) +{ + wi(); *out << "<column>" << endl; indent(); + writeString( name, value ); undent(); + wi(); *out << "</column>" << endl; +} + +void KDEVDLG2UI::writeColor( const TQString& name, const TQString& value ) +{ + int color = value.toInt(); + + int r = color & 0x00ff0000 >> 16; + int g = color & 0x0000ff00 >> 8; + int b = color & 0x000000ff; + + wi(); *out << "<property>" << endl; indent(); //###FIX + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<color>" << endl; indent(); + wi(); *out << "<red>" << r << "</red>" << endl; + wi(); *out << "<green>" << g << "</green>" << endl; + wi(); *out << "<blue>" << b << "</blue>" << endl; undent(); + wi(); *out << "</color>" << endl; + wi(); *out << "</property>" << endl; +} + +void KDEVDLG2UI::writeStyles( const TQStringList styles, bool isFrame ) +{ + if ( isFrame ) { + bool defineFrame = FALSE; + TQString shadow = "NoFrame"; + TQString shape = "StyledPanel"; + int width = 2; + if ( styles.contains( "WS_EX_STATICEDGE" ) ) { + shadow = "Plain"; + width = 1; + defineFrame = TRUE; + } + if ( styles.contains( "WS_EX_CLIENTEDGE" ) ) { + shadow = "Sunken"; + defineFrame = TRUE; + } + if ( styles.contains( "WS_EX_DLGMODALFRAME" ) ) { + shadow = "Raised"; + defineFrame = TRUE; + } + if ( !styles.contains( "WS_BORDER" ) ) { + shape = "NoFrame"; + defineFrame = TRUE; + } + + if ( defineFrame ) { + writeEnum( "frameShape", "StyledPanel" ); + writeEnum( "frameShadow", shadow ); + writeNumber( "lineWidth", width ); + } + } + + if ( styles.contains("WS_DISABLED") ) + writeBool("enabled", FALSE ); + if ( styles.contains("WS_EX_ACCEPTFILES") ) + writeBool("acceptDrops", TRUE ); + if ( styles.contains("WS_EX_TRANSPARENT") ) + writeBool("autoMask", TRUE ); + if ( !styles.contains("WS_TABSTOP") ) + writeEnum("focusPolicy", "NoFocus"); +} + +/*! + Constructs a KDEVDLG2UI object +*/ + +KDEVDLG2UI::KDEVDLG2UI( TQTextStream* input, const TQString& name ) +{ + className = name; + writeToFile = TRUE; + in = input; + indentation = 0; + out = 0; +} + +/*! + Destructs the KDEVDLG2UI object +*/ + +KDEVDLG2UI::~KDEVDLG2UI() +{ +} + +/*! + Parses the input stream and writes the output to files. +*/ + +bool KDEVDLG2UI::parse() +{ + TQFile fileOut; + TQString buffer; + + if ( writeToFile ) { + + TQString outputFile = TQString( className ) + ".ui"; + fileOut.setName( outputFile ); + if (!fileOut.open( IO_WriteOnly ) ) + qFatal( "kdevdlg2ui: Could not open output file '%s'", outputFile.latin1() ); + out = new TQTextStream( &fileOut ); + targetFiles.append( outputFile ); + } else { + out = new TQTextStream( &buffer, IO_WriteOnly ); + } + + writeDialog( className ); + + delete out; + out = 0; + + return TRUE; +} + +/*! + Parses the input stream and writes the output in \a get. +*/ +bool KDEVDLG2UI::parse( TQStringList& get ) +{ + writeToFile = FALSE; + bool result = parse(); + get = target; + return result; +} + +/*! + Replaces characters like '&', '<' and '>' with the proper encoding. +*/ +void KDEVDLG2UI::cleanString( TQString * text ) +{ + if ( !text ) return; + text->replace( "\\n", "\n" ); + text->replace( "\\t", "\t" ); + text->replace( "&", "&" ); + text->replace( "<", "<" ); + text->replace( ">", ">" ); +} + +/*! + Builds a number of UI dialog out of the current input stream +*/ +bool KDEVDLG2UI::writeDialog( const TQString& name ) +{ + *out << "<!DOCTYPE UI><UI>" << endl; + writeClass( name ); + + while ( !in->eof() ) { + + line = in->readLine().simplifyWhiteSpace(); + + if ( line.left( 4 ) == "data" ) { + // ignore data section + while ( line.left( 1 ) != "}" && !in->eof() ) { + line = in->readLine(); + } + } else if ( line.left( 4 ) == "item" ) { + writeWidgetStart( line.section( "//", 0, 0 ).section( " ", 1, 1 ) ); + } else if ( line.left( 1 ) == "{" ) { + indent(); + } else if ( line.left( 1 ) == "}" ) { + undent(); + writeWidgetEnd(); + } else if ( line.left( 4 ) == "Name" ) { + TQString name = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + writeString( "name", name ); + } else if ( line.left( 4 ) == "Font" ) { + TQString font = line.section( "//", 0, 0 ).section( "\"", 1 ); + TQString family = font.section("\"", 1, 1 ); + int pointSize = font.section("\"", 3, 3 ).toInt(); + //int weight = font.section("\"", 5, 5 ).toInt(); + //bool italic = ( font.section("\"", 7, 7 ) == "TRUE" ); + writeFont( family, pointSize ); // weight, italic ? + } else if ( line.left( 9 ) == "IsEnabled" ) { + bool isEnabled = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "enabled", isEnabled ); + } else if ( line.left( 12 ) == "AcceptsDrops" ) { + bool acceptDrops = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "acceptDrops", acceptDrops ); + } else if ( line.left( 12 ) == "isAutoResize" ) { + bool isAutoResize = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "autoResize", isAutoResize ); //###FIX: obsolete + } else if ( line.left( 12 ) == "isAutoRepeat" ) { + bool isAutoRepeat = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "autoRepeat", isAutoRepeat ); + } else if ( line.left( 9 ) == "isDefault" ) { + bool isDefault = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "default", isDefault ); + } else if ( line.left( 13 ) == "isAutoDefault" ) { + bool isAutoDefault = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "autoDefault", isAutoDefault ); + } else if ( line.left( 14 ) == "isToggleButton" ) { + bool isToggleButton = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "toggleButton", isToggleButton ); + } else if ( line.left( 11 ) == "isToggledOn" ) { + bool isToggledOn = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "on", isToggledOn ); + } else if ( line.left( 8 ) == "hasFrame" ) { + bool hasFrame = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "frame", hasFrame ); + } else if ( line.left( 10 ) == "isReadOnly" ) { + bool isReadOnly = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "readOnly", isReadOnly ); + } else if ( line.left( 9 ) == "isChecked" ) { + bool isChecked = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "checked", isChecked ); + } else if ( line.left( 16 ) == "isAutoCompletion" ) { + bool isAutoCompl = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "autoCompletion", isAutoCompl ); + } else if ( line.left( 8 ) == "EditText" ) { + bool editText = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "editable", editText ); + } else if ( line.left( 10 ) == "isTracking" ) { + bool isTracking = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "tracking", isTracking ); + } else if ( line.left( 16 ) == "isMultiSelection" ) { + bool isMultiSel = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "multiSelection", isMultiSel ); + } else if ( line.left( 21 ) == "isAllColumnsShowFocus" ) { + bool isAllColsShowFocus = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "allColumnsShowFocus", isAllColsShowFocus ); + } else if ( line.left( 16 ) == "isRootDecorated" ) { + bool isRootDec = + ( line.section( "//", 0, 0 ).section("\"", 1, 1 ) == "true" ); + writeBool( "rootIsDecorated", isRootDec ); + } else if ( line.left( 1 ) == "X" ) { + int x = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + line = in->readLine().stripWhiteSpace(); + int y = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + line = in->readLine().stripWhiteSpace(); + int w = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + line = in->readLine().stripWhiteSpace(); + int h = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeRect( "geometry", x, y, w, h ); + } else if ( line.left( 8 ) == "MinWidth" ) { + int minw = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "minimumWidth", minw ); + } else if ( line.left( 9 ) == "MinHeight" ) { + int minh = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "minimumHeight", minh ); + } else if ( line.left( 8 ) == "MaxWidth" ) { + int maxw = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "maximumWidth", maxw ); + } else if ( line.left( 9 ) == "MaxHeight" ) { + int maxh = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "maximumHeight", maxh ); + } else if ( line.left( 4 ) == "Text" ) { + TQString text = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & text ); + writeString( "text", text ); + } else if ( line.left( 5 ) == "Title" ) { + TQString title = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & title ); + writeString( "title", title ); + } else if ( line.left( 5 ) == "Buddy" ) { + TQString buddy = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + writeString( "buddy", buddy ); + } else if ( line.left( 14 ) == "SpecialValText" ) { + TQString text = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + writeString( "specialValueText", text ); + } else if ( line.left( 6 ) == "Prefix" ) { + TQString text = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + writeString( "prefix", text ); + } else if ( line.left( 6 ) == "Suffix" ) { + TQString text = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + writeString( "suffix", text ); + } else if ( line.left( 5 ) == "Value" ) { + int v = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "value", v ); + } else if ( line.left( 8 ) == "MinValue" ) { + int minv = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "minValue", minv ); + } else if ( line.left( 8 ) == "MaxValue" ) { + int maxv = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "maxValue", maxv ); + } else if ( line.left( 9 ) == "SizeLimit" ) { + int limit = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "sizeLimit", limit ); + } else if ( line.left( 9 ) == "MaxLength" ) { + int maxl = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "maxLength", maxl ); + } else if ( line.left( 8 ) == "MaxCount" ) { + int maxc = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "maxCount", maxc ); + } else if ( line.left( 14 ) == "CursorPosition" ) { + int pos = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "cursorPosition", pos ); + } else if ( line.left( 9 ) == "NumDigits" ) { + int digits = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "numDigits", digits ); + } else if ( line.left( 10 ) == "TotalSteps" ) { + int steps = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "totalSteps", steps ); + } else if ( line.left( 12 ) == "TreeStepSize" ) { + int stepSize = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "treeStepSize", stepSize ); + } else if ( line.left( 10 ) == "ItemMargin" ) { + int margin = line.section( "//", 0, 0 ).section("\"", 1, 1 ).toInt(); + writeNumber( "itemMargin", margin ); + } else if ( line.left( 7 ) == "ToolTip" ) { + TQString text = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + writeString( "toolTip", text ); + } else if ( line.left( 9 ) == "QuickHelp" ) { + TQString text = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & text ); + writeString( "whatsThis", text ); + } else if ( line.left( 15 ) == "InsertionPolicy" ) { + TQString policy = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & policy ); + writeEnum( "insertionPolicy", policy ); //###FIX: TQComboBox:: + } else if ( line.left( 11 ) == "Orientation" ) { + TQString orientation = + line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & orientation ); + if ( orientation == "V" ) + writeEnum( "orientation", "TQt::Vertical" ); + else if ( orientation == "H" ) + writeEnum( "orientation", "TQt::Horizontal" ); + } else if ( line.left( 14 ) == "vScrollBarMode" ) { + TQString mode = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & mode ); + writeEnum( "vScrollBarMode", mode ); + } else if ( line.left( 14 ) == "hScrollBarMode" ) { + TQString mode = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & mode ); + writeEnum( "hScrollBarMode", mode ); + } else if ( line.left( 7 ) == "Entries" ) { + TQString entries = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & entries ); + TQStringList l = TQStringList::split( '\n', entries ); + for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it ) + writeItem( "text", *it ); + } else if ( line.left( 7 ) == "Columns" ) { + TQString columns = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & columns ); + TQStringList l = TQStringList::split( '\n', columns ); + for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it ) + writeColumn( "text", *it ); + } else if ( line.left( 6 ) == "BgMode" ) { + TQString mode = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & mode ); + writeString( "backgroundMode", mode ); //###FIX: TQWidget::: + } else if ( line.left( 10 ) == "BgPalColor" ) { + TQString color = line.section( "//", 0, 0 ).section("\"", 1, 1 ); + cleanString( & color ); + writeColor( "paletteBackgroundColor", color ); + } //else { + //if ( line.length() ) + //qDebug( "IGNORED: %s", line.latin1() ); + //} + } + *out << "</UI>" << endl; + return TRUE; +} + diff --git a/tools/designer/plugins/kdevdlg/kdevdlg2ui.h b/tools/designer/plugins/kdevdlg/kdevdlg2ui.h new file mode 100644 index 000000000..f77415e27 --- /dev/null +++ b/tools/designer/plugins/kdevdlg/kdevdlg2ui.h @@ -0,0 +1,90 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef KDEVDLG2UI_H +#define KDEVDLG2UI_H + +#include <qtextstream.h> +#include <qfile.h> +#include <qstringlist.h> + +class KDEVDLG2UI +{ +public: + KDEVDLG2UI( TQTextStream* input, const TQString& name = "dialog" ); + ~KDEVDLG2UI(); + + bool parse(); + bool parse ( TQStringList& get ); + + TQStringList targetFiles; + +protected: + + bool writeDialog( const TQString& name ); + + TQString className; + TQString line; + TQTextStream *in; + TQStringList target; + + void cleanString( TQString* text ); + + void indent(); + void undent(); + void wi(); + + void writeClass( const TQString& name ); + void writeCString( const TQString& name, const TQString& value ); + void writeString( const TQString& name, const TQString& value ); + void writeRect( const TQString& name, int x, int y, int w, int h ); + void writeFont( const TQString& family, int pointsize ); + void writeBool( const TQString& name, bool value ); + void writeNumber( const TQString& name, int value ); + void writeEnum( const TQString& name, const TQString& value ); + void writeSet( const TQString& name, const TQString& value ); + void writeItem( const TQString& name, const TQString& value ); + void writeColumn( const TQString& name, const TQString& value ); + void writeColor( const TQString& name, const TQString& value ); + void writeStyles( const TQStringList styles, bool isFrame ); + void writeWidgetStart( const TQString& qclass ); + void writeWidgetEnd(); + +private: + int indentation; + bool writeToFile; + TQTextStream* out; +}; + +#endif diff --git a/tools/designer/plugins/kdevdlg/main.cpp b/tools/designer/plugins/kdevdlg/main.cpp new file mode 100644 index 000000000..5c5fc0de1 --- /dev/null +++ b/tools/designer/plugins/kdevdlg/main.cpp @@ -0,0 +1,120 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include <filterinterface.h> + +#include <qapplication.h> +#include <qstring.h> +#include <qdir.h> + +#include "kdevdlg2ui.h" + +class KDevDlgFilter : public ImportFilterInterface, public TQLibraryInterface +{ +public: + KDevDlgFilter(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface **iface ); + Q_REFCOUNT; + + TQStringList featureList() const; + TQStringList import( const TQString& filter, const TQString& filename ); + + bool init(); + void cleanup(); + bool canUnload() const; +}; + +KDevDlgFilter::KDevDlgFilter() +{ +} + +TQRESULT KDevDlgFilter::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)(ImportFilterInterface*)this; + else if ( uuid == IID_QFeatureList ) + *iface = (TQFeatureListInterface*)this; + else if ( uuid == IID_ImportFilter ) + *iface = (ImportFilterInterface*)this; + else if ( uuid == IID_QLibrary ) + *iface = (TQLibraryInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +TQStringList KDevDlgFilter::featureList() const +{ + TQStringList list; + list << "KDevelop Dialog Files (*.kdevdlg)" ; + return list; +} + +TQStringList KDevDlgFilter::import( const TQString &, const TQString& filename ) +{ + TQFile file( filename ); + if ( !file.open( IO_ReadOnly ) ) + qWarning( "uic: Could not open file '%s' ", filename.latin1() ); + TQTextStream in; + in.setDevice( &file ); + + TQString name = filename.right( filename.length() - filename.findRev( TQDir::separator() ) - 1 ).section( ".", 0, 0 ); + KDEVDLG2UI c( &in, name ); + TQStringList files; + c.parse(); + return c.targetFiles; +} + +bool KDevDlgFilter::init() +{ + return TRUE; +} + +void KDevDlgFilter::cleanup() +{ +} + +bool KDevDlgFilter::canUnload() const +{ + return TRUE; +} + +Q_EXPORT_COMPONENT() +{ + Q_CREATE_INSTANCE( KDevDlgFilter ) +} diff --git a/tools/designer/plugins/plugins.pro b/tools/designer/plugins/plugins.pro new file mode 100644 index 000000000..355f5d0f4 --- /dev/null +++ b/tools/designer/plugins/plugins.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs +PLUGIN_DIRS = wizards \ + cppeditor \ + dlg \ + glade \ + rc \ + kdevdlg +shared:SUBDIRS *= $$PLUGIN_DIRS +dll:SUBDIRS *= $$PLUGIN_DIRS diff --git a/tools/designer/plugins/rc/main.cpp b/tools/designer/plugins/rc/main.cpp new file mode 100644 index 000000000..b89ba98da --- /dev/null +++ b/tools/designer/plugins/rc/main.cpp @@ -0,0 +1,117 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include <filterinterface.h> + +#include <qapplication.h> + +#include "rc2ui.h" + +class RCFilter : public ImportFilterInterface, public TQLibraryInterface +{ +public: + RCFilter(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface **iface ); + Q_REFCOUNT; + + TQStringList featureList() const; + TQStringList import( const TQString& filter, const TQString& filename ); + + bool init(); + void cleanup(); + bool canUnload() const; +}; + +RCFilter::RCFilter() +{ +} + +TQRESULT RCFilter::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)(ImportFilterInterface*)this; + else if ( uuid == IID_QFeatureList ) + *iface = (TQFeatureListInterface*)this; + else if ( uuid == IID_ImportFilter ) + *iface = (ImportFilterInterface*)this; + else if ( uuid == IID_QLibrary ) + *iface = (TQLibraryInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +TQStringList RCFilter::featureList() const +{ + TQStringList list; + list << "Microsoft Resource Files (*.rc)" ; + return list; +} + +TQStringList RCFilter::import( const TQString &, const TQString& filename ) +{ + TQFile file( filename ); + if ( !file.open( IO_ReadOnly ) ) + qWarning( "uic: Could not open file '%s' ", filename.latin1() ); + TQTextStream in; + in.setDevice( &file ); + + RC2UI c( &in ); + TQStringList files; + c.parse(); + return c.targetFiles; +} + +bool RCFilter::init() +{ + return TRUE; +} + +void RCFilter::cleanup() +{ +} + +bool RCFilter::canUnload() const +{ + return TRUE; +} + +Q_EXPORT_COMPONENT() +{ + Q_CREATE_INSTANCE( RCFilter ) +} diff --git a/tools/designer/plugins/rc/rc.pro b/tools/designer/plugins/rc/rc.pro new file mode 100644 index 000000000..27ad4448d --- /dev/null +++ b/tools/designer/plugins/rc/rc.pro @@ -0,0 +1,11 @@ +TEMPLATE = lib +CONFIG += qt warn_on release plugin +HEADERS = rc2ui.h +SOURCES = main.cpp rc2ui.cpp +DESTDIR = ../../../../plugins/designer +TARGET = rcplugin +INCLUDEPATH += ../../interfaces + + +target.path += $$plugins.path/designer +INSTALLS += target diff --git a/tools/designer/plugins/rc/rc2ui.cpp b/tools/designer/plugins/rc/rc2ui.cpp new file mode 100644 index 000000000..cf5887f24 --- /dev/null +++ b/tools/designer/plugins/rc/rc2ui.cpp @@ -0,0 +1,888 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "rc2ui.h" +#include <qdir.h> + +/// some little helpers /// + +void RC2UI::wi() +{ + for ( int i = 0; i < indentation; i++ ) + *out << " "; +} + +void RC2UI::indent() +{ + indentation++; +} + +void RC2UI::undent() +{ + indentation--; +} + +TQString RC2UI::stripQM( const TQString& string ) +{ + return string.mid( 1, string.length()-2 ); +} + +TQStringList RC2UI::splitStyles( const TQString& styles, char sep ) +{ + TQString s = styles; + TQString style; + TQStringList l; + while ( s.find( sep ) > -1 ) { + style = s.left( s.find( sep ) ); + l << style.stripWhiteSpace(); + s = s.right( s.length() - style.length() -1 ); + } + if ( !s.isEmpty() ) + l << s.stripWhiteSpace(); + return l; +} + +TQString RC2UI::parseNext( TQString& arg, char sep ) +{ + TQString next = arg.left( arg.find(sep) ); + arg = arg.right( arg.length() - next.length() - 1 ); + return next; +} + +void RC2UI::writeClass( const TQString& name ) +{ + wi(); *out << "<class>" << name << "</class>" << endl; +} + +void RC2UI::writeCString( const TQString& name, const TQString& value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<cstring>" << value << "</cstring>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void RC2UI::writeString( const TQString& name, const TQString& value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<string>" << value << "</string>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void RC2UI::writeRect( const TQString& name, int x, int y, int w, int h ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<rect>" << endl; indent(); + wi(); *out << "<x>" << int(double(x)*1.5) << "</x>" << endl; + wi(); *out << "<y>" << int(double(y)*1.65) << "</y>" << endl; + wi(); *out << "<width>" << int(double(w)*1.5) << "</width>" << endl; + wi(); *out << "<height>" << int(double(h)*1.65) << "</height>" << endl; undent(); + wi(); *out << "</rect>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void RC2UI::writeFont( const TQString& family, int pointsize ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>font</name>" << endl; + wi(); *out << "<font>" << endl; indent(); + wi(); *out << "<family>" << family << "</family>" << endl; + wi(); *out << "<pointsize>" << pointsize << "</pointsize>" << endl; undent(); + wi(); *out << "</font>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void RC2UI::writeBool( const TQString& name, bool value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<bool>" << (value ? "true" : "false") << "</bool>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void RC2UI::writeNumber( const TQString& name, int value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<number>" << value << "</number>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void RC2UI::writeEnum( const TQString& name, const TQString& value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<enum>" << value << "</enum>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void RC2UI::writeSet( const TQString& name, const TQString& value ) +{ + wi(); *out << "<property>" << endl; indent(); + wi(); *out << "<name>" << name << "</name>" << endl; + wi(); *out << "<set>" << value << "</set>" << endl; undent(); + wi(); *out << "</property>" << endl; +} + +void RC2UI::writeStyles( const TQStringList styles, bool isFrame ) +{ + if ( isFrame ) { + bool defineFrame = FALSE; + TQString shadow = "NoFrame"; + TQString shape = "StyledPanel"; + int width = 2; + if ( styles.contains( "WS_EX_STATICEDGE" ) ) { + shadow = "Plain"; + width = 1; + defineFrame = TRUE; + } + if ( styles.contains( "WS_EX_CLIENTEDGE" ) ) { + shadow = "Sunken"; + defineFrame = TRUE; + } + if ( styles.contains( "WS_EX_DLGMODALFRAME" ) ) { + shadow = "Raised"; + defineFrame = TRUE; + } + if ( !styles.contains( "WS_BORDER" ) ) { + shape = "NoFrame"; + defineFrame = TRUE; + } + + if ( defineFrame ) { + writeEnum( "frameShape", "StyledPanel" ); + writeEnum( "frameShadow", shadow ); + writeNumber( "lineWidth", width ); + } + } + + if ( styles.contains("WS_DISABLED") ) + writeBool("enabled", FALSE ); + if ( styles.contains("WS_EX_ACCEPTFILES") ) + writeBool("acceptDrops", TRUE ); + if ( styles.contains("WS_EX_TRANSPARENT") ) + writeBool("autoMask", TRUE ); + if ( !styles.contains("WS_TABSTOP") ) + writeEnum("focusPolicy", "NoFocus"); +} + +/*! + Constructs a RC2UI object +*/ + +RC2UI::RC2UI( TQTextStream* input ) +: blockStart1( "/////////////////////////////////////////////////////////////////////////////" ), + blockStart2( "//" ) +{ + writeToFile = TRUE; + in = input; + indentation = 0; + out = 0; +} + +/*! + Destructs the RC2UI object +*/ + +RC2UI::~RC2UI() +{ +} + +/*! + Parses the input stream and writes the output to files. +*/ + +bool RC2UI::parse() +{ + while ( !in->eof() ) { + while ( line != blockStart1 && !in->eof() ) + line = in->readLine(); + if ( in->eof() ) + return FALSE; + while ( line != blockStart2 && !in->eof() ) + line = in->readLine(); + if ( in->eof() ) + return FALSE; + + line = in->readLine(); + + if ( line.left(3) == "// " && !in->eof() ) { + TQString type = line.right( line.length() - 3 ); + if ( in->readLine() == "//" && in->readLine().isEmpty() && !in->eof() ) { + if ( type == "Dialog" ) { + if ( !makeDialog() ) + return FALSE; + } +/* + else if ( type == "Bitmap" ) { + if ( !makeBitmap() ) + return FALSE; + } else if ( type == "String Table" ) { + if ( !makeStringTable() ) + return FALSE; + } else if ( type == "Accelerator" ) { + if ( !makeAccelerator() ) + return FALSE; + } else if ( type == "Cursor" ) { + if ( !makeCursor() ) + return FALSE; + } else if ( type == "HTML" ) { + if ( !makeHTML() ) + return FALSE; + } else if ( type == "Icon" ) { + if ( !makeIcon() ) + return FALSE; + } else if ( type == "Version" ) { + if ( !makeVersion() ) + return FALSE; + } +*/ + } + } else + return FALSE; + } + return TRUE; +} + +/*! + Parses the input stream and writes the output in \a get. +*/ + +bool RC2UI::parse( TQStringList& get ) +{ + writeToFile = FALSE; + bool result = parse(); + get = target; + return result; +} + +/*! + Retrieves a unique name starting with \a start +*/ +TQString RC2UI::useName( const TQString& start ) +{ + TQString name = start; + int id = 1; + + while ( usedNames.contains( name ) ) { + name = start + TQString( "%1" ).arg( id ); + id++; + } + + usedNames.append(name); + + return name; +} + + +/*! + Builds a number of UI dialog out of the current input stream +*/ + +bool RC2UI::makeDialog() +{ + line = in->readLine(); + do { + TQFile fileOut; + TQString buffer; + int count; + TQCString className; + uint x, y, w, h; + uint endDesc; + bool space = FALSE; + for ( endDesc = 0; endDesc < line.length() ; endDesc++ ) { + char c = (TQChar)line.at(endDesc); + if ( space && (c >= '0') && (c <= '9') ) + break; + space = c==' '; + } + + TQString desc = line.left(endDesc-1); + line = line.right( line.length() - endDesc ); + + className = parseNext( desc, ' ' ); + + count = sscanf( line, "%u, %u, %u, %u", &x, &y, &w, &h ); + + if ( !count && count == EOF ) + return FALSE; + + char property[256]; + TQStringList styles; + TQStringList extendedStyles; + TQString caption = ""; + TQString baseClass = ""; + TQString widgetType; + TQString widgetName; + TQString arguments; + int pointsize = 10; + TQString fontname; + do { + line = ""; + do { + if ( in->eof() ) + return TRUE; + line += in->readLine(); + } while ( line[(int)line.length()-1] == '|' || + line[(int)line.length()-1] == ',' ); + count = sscanf( line, "%s", property ); + line = line.right( line.length() - line.find(" ") -1 ); + if ( TQString(property) == "STYLE" ) { + styles = splitStyles(line); + if ( styles.contains( "WS_CAPTION" ) ) + baseClass = "TQDialog"; + else + baseClass = "TQWidget"; + } else if ( TQString(property) == "CAPTION" ) { + caption = stripQM( line ); + } else if ( TQString(property) == "FONT" ) { + TQString pt = line.left( line.find(",") ); + pointsize = pt.toInt(); + fontname = stripQM(line.right( line.length() - line.find(",") - 2 )); + } + } while ( line != "BEGIN" ); + + if ( writeToFile ) { + + TQString outputFile = TQString(className) + ".ui"; + fileOut.setName( outputFile ); + if (!fileOut.open( IO_WriteOnly ) ) + qFatal( "rc2ui: Could not open output file '%s'", outputFile.latin1() ); + out = new TQTextStream( &fileOut ); + targetFiles.append( outputFile ); + } else { + out = new TQTextStream( &buffer, IO_WriteOnly ); + } + + *out << "<!DOCTYPE UI><UI>" << endl; + writeClass( className ); + wi(); *out << "<widget>"<< endl; indent(); + writeClass( baseClass ); + writeCString( "name", className ); + writeRect( "geometry", x, y, w, h ); + writeString( "caption", caption ); + writeFont( fontname, pointsize ); + + do { + if ( in->eof() ) + return TRUE; + + line = in->readLine().stripWhiteSpace(); + if ( line == "END" ) + continue; + + widgetType = parseNext(line, ' '); + arguments = line.stripWhiteSpace(); + while ( arguments[(int)arguments.length()-1] == ',' || + arguments[(int)arguments.length()-1] == '|' ) + arguments += " "+in->readLine().stripWhiteSpace(); + + wi(); *out << "<widget>" << endl; indent(); + + WidgetType ID = IDUnknown; + TQString controlType; + TQString widgetID; + TQString widgetText; + bool hasText = FALSE; + bool isControl = FALSE; + bool isFrame = FALSE; + + if ( widgetType == "PUSHBUTTON" ) { + ID = IDPushButton; + hasText = TRUE; + } else if ( widgetType == "DEFPUSHBUTTON" ) { + ID = IDPushButton; + hasText = TRUE; + } else if ( widgetType == "LTEXT" ) { + ID = IDLabel; + hasText = TRUE; + } else if ( widgetType == "CTEXT" ) { + ID = IDLabel; + hasText = TRUE; + } else if ( widgetType == "RTEXT" ) { + ID = IDLabel; + hasText = TRUE; + } else if ( widgetType == "EDITTEXT" ) { + ID = IDLineEdit; + } else if ( widgetType == "GROUPBOX" ) { + ID = IDGroupBox; + hasText = TRUE; + } else if ( widgetType == "COMBOBOX" ) { + ID = IDComboBox; + } else if ( widgetType == "LISTBOX" ) { + ID = IDListBox; + } else if ( widgetType == "SCROLLBAR" ) { + ID = IDScrollBar; + } else if ( widgetType == "CHECKBOX" ) { + ID = IDCheckBox; + hasText = TRUE; + } else if ( widgetType == "RADIOBUTTON" ) { + ID = IDRadioButton; + hasText = TRUE; + } else if ( widgetType == "CONTROL" ) { + isControl = TRUE; + widgetText = stripQM(parseNext( arguments )); + widgetID = parseNext( arguments ); + controlType = stripQM(parseNext( arguments )); + styles = splitStyles(parseNext( arguments )); + + if ( controlType == "Static" ) { + ID = IDLabel; + } else if ( controlType == "Button" ) { + if ( styles.contains("BS_AUTOCHECKBOX") || + styles.contains("BS_3STATE") ) + ID = IDCheckBox; + else if ( styles.contains("BS_AUTORADIOBUTTON") ) + ID = IDRadioButton; + } else if ( controlType == "msctls_updown32" ) { + ID = IDSpinBox; + } else if ( controlType == "msctls_progress32" ) { + ID = IDProgressBar; + } else if ( controlType == "msctls_trackbar32" ) { + ID = IDSlider; + } else if ( controlType == "SysListView32" ) { + ID = IDIconView; + } else if ( controlType == "SysTreeView32" ) { + ID = IDListView; + } else if ( controlType == "SysTabControl32" ) { + ID = IDTabWidget; + } else if ( controlType == "SysAnimate32" ) { + ID = IDLabel; + } else if ( controlType == "RICHEDIT" ) { + ID = IDMultiLineEdit; + } else if ( controlType == "ComboBoxEx32" ) { + ID = IDComboBox; + } else if ( controlType == "" ) { + ID = IDCustom; + } else { + ID = IDUnknown; + } + } else + ID = IDUnknown; + + if ( hasText ) + widgetText = stripQM(parseNext( arguments )); + + if ( isControl ) { + x = parseNext( arguments ).toInt(); + y = parseNext( arguments ).toInt(); + w = parseNext( arguments ).toInt(); + h = parseNext( arguments ).toInt(); + } else { + widgetID = parseNext( arguments ); + x = parseNext( arguments ).toInt(); + y = parseNext( arguments ).toInt(); + w = parseNext( arguments ).toInt(); + h = parseNext( arguments ).toInt(); + styles.clear(); + } + + do { + extendedStyles = splitStyles(parseNext( arguments )); + for ( uint i = 0; i < extendedStyles.count(); i++ ) + styles << (*extendedStyles.at(i)); + } while ( arguments.find(',') > -1 ); + + switch ( ID ) { + case IDWidget: + break; + case IDPushButton: + { + writeClass("TQPushButton"); + writeCString( "name", useName("PushButton_"+widgetID) ); + writeRect( "geometry", x, y, w, h ); + writeString( "text", widgetText ); + if ( widgetType == "DEFPUSHBUTTON" ) + writeBool( "default", TRUE ); + } + break; + case IDLabel: + { + isFrame = TRUE, + writeClass("TQLabel"); + writeCString( "name", useName("Label_"+widgetID) ); + writeRect( "geometry", x,y,w,h ); + writeString( "text", widgetText ); + TQString align; + if ( !styles.contains("SS_CENTERIMAGE") ) + align += "|AlignTop"; + else + align += "|AlignVCenter"; + if ( widgetType == "LTEXT" ) { + align += "|AlignLeft"; + } else if ( widgetType == "CTEXT") { + align += "|AlignHCenter"; + } else if ( widgetType == "RTEXT") { + align += "|AlignRight"; + } + writeSet("alignment", align ); + } + break; + case IDCheckBox: + { + writeClass("TQCheckBox"); + writeCString("name", useName("CheckBox_"+widgetID) ); + writeRect("geometry", x,y,w,h); + writeString("text", widgetText ); + if ( styles.contains( "BS_3STATE" ) ) + writeBool( "tristate", TRUE ); + } + break; + case IDRadioButton: + { + writeClass("TQRadioButton"); + writeCString("name", useName("RadioButton_"+widgetID) ); + writeRect("geometry", x,y,w,h); + writeString("text", widgetText ); + } + break; + case IDGroupBox: + { + isFrame = TRUE; + writeClass("TQGroupBox"); + writeCString( "name", useName("GroupBox_"+widgetID) ); + writeRect( "geometry", x,y,w,h ); + writeString( "title", widgetText ); + if ( !styles.contains( "WS_BORDER" ) ) + styles.append( "WS_BORDER" ); + } + break; + case IDLineEdit: + { + if ( !styles.contains("ES_MULTILINE") ) { + writeClass("TQLineEdit"); + writeCString( "name", useName("LineEdit_"+widgetID) ); + } else { + writeClass("TQMultiLineEdit"); + writeCString( "name", useName("MultiLineEdit_"+widgetID) ); + } + writeRect( "geometry", x,y,w,h ); + TQString align = "AlignTop"; + if ( styles.contains("ES_CENTER") ) + align+="|AlignHCenter"; + else if ( styles.contains("ES_RIGHT") ) + align+="|AlignRight"; + else + align+="|AlignLeft"; + writeSet("alignment", align); + } + break; + case IDMultiLineEdit: + { + writeClass("TQMultiLineEdit"); + writeCString("name", useName("MultiLineEdit_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + } + break; + case IDIconView: + { + isFrame = TRUE; + writeClass("TQIconView"); + writeCString("name", useName("IconView_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + if ( !styles.contains( "LVS_SINGLESEL" ) ) + writeEnum( "selectionMode", "Extended" ); + if ( styles.contains( "LVS_NOLABELWRAP" ) ) + writeBool("wordWrapIconText", FALSE ); + } + break; + case IDListView: + { + isFrame = TRUE; + writeClass("TQListView"); + writeCString("name", useName("ListView_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + if ( styles.contains( "TVS_LINESATROOT" ) ) + writeBool( "rootIsDecorated", TRUE ); + if ( styles.contains( "TVS_FULLROWSELECT" ) ) + writeBool( "allColumnsShowFocus", TRUE ); + } + break; + case IDProgressBar: + { + isFrame = TRUE; + writeClass("TQProgressBar"); + writeCString("name", useName("ProgressBar_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + if ( styles.contains("TBS_VERT") ) + writeEnum("orientation", "Vertical"); + else + writeEnum("orientation", "Horizontal"); + } + break; + case IDTabWidget: + { + writeClass("TQTabWidget"); + writeCString("name", useName("TabWidget_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + wi(); *out << "<widget>" << endl; indent(); + writeClass("TQWidget"); + wi(); *out << "<attribute>" << endl; indent(); + wi(); *out << "<name>title</name>" << endl; + wi(); *out << "<string>Tab1</string>" << endl; undent(); + wi(); *out << "</attribute>" << endl; undent(); + wi(); *out << "</widget>" << endl; + } + break; + case IDSpinBox: + { + isFrame = TRUE; + writeClass("TQSpinBox"); + writeCString("name", useName("SpinBox_"+widgetID) ); + writeRect("geometry", x,y,w,h); + } + break; + case IDSlider: + { + writeClass("TQSlider"); + writeCString("name", useName("Slider_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + if ( styles.contains("TBS_VERT") ) + writeEnum("orientation", "Vertical"); + else + writeEnum("orientation", "Horizontal"); + if ( !styles.contains("TBS_NOTICKS") ) + writeEnum("tickmarks", "Left" ); + } + break; + case IDComboBox: + { + writeClass("TQComboBox"); + writeCString("name", useName("ComboBox_"+widgetID) ); + if ( isControl ) + writeRect( "geometry", x,y,w,14 ); + else + writeRect( "geometry", x,y,w,h ); + } + break; + case IDListBox: + { + isFrame = TRUE; + writeClass("TQListBox"); + writeCString("name", useName("ListBox_"+widgetID) ); + writeRect( "geometry", x,y,w,h ); + if ( styles.contains("WS_HSCROLL") ) + writeEnum("hScrollBarMode", "Auto"); + else + writeEnum("hScrollBarMode", "AlwaysOff"); + if ( styles.contains("WS_VSCROLL") ) + writeEnum("vScrollBarMode", "Auto"); + else + writeEnum("vScrollBarMode", "AlwaysOff"); + if ( styles.contains("LBS_EXTENDEDSEL") ) + writeEnum("selectionMode", "Extended"); + else if ( styles.contains("LBS_MULTIPLESEL") ) + writeEnum("selectionMode", "Multi"); + else if ( styles.contains("LBS_NOSEL") ) + writeEnum("selectionMode", "NoSelection"); + else + writeEnum("selectionMode", "Single"); + if ( !styles.contains( "NO WS_BORDER" ) ) + styles.append( "WS_BORDER" ); + } + break; + case IDScrollBar: + { + writeClass("TQScrollBar"); + writeCString("name", useName("ScrollBar_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + if ( styles.contains("SBS_VERT") ) + writeEnum("orientation", "Vertical"); + else + writeEnum("orientation", "Horizontal"); + } + break; + case IDCustom: + { + writeClass("TQLabel"); + writeCString("name", useName("Custom_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + writeString("text", "Create a custom widget and place it here." ); + } + default: + { + writeClass("TQLabel"); + writeCString("name", useName("Unknown_"+widgetID) ); + writeRect("geometry", x,y,w,h ); + writeString("text", TQString("No support for %1.").arg(controlType) ); + } + break; + } + + writeStyles( styles, isFrame ); + + styles.clear(); + + undent(); + wi(); *out << "</widget>" << endl; + } while ( line != "END" ); + + undent(); + wi(); *out << "</widget>" << endl; + *out << "</UI>" << endl; + + do { + line = in->readLine(); + } while ( line.isEmpty() ); + + if ( !writeToFile ) + target.append( buffer.copy() ); + + if (out) { + delete out; + out = 0; + } + fileOut.close(); + + } while ( line != blockStart1 ); + + return TRUE; +} + +/*! Not yet implemented +*/ + +bool RC2UI::makeBitmap() +{ + return TRUE; +} + +/*! Not yet implemented +*/ + +bool RC2UI::makeAccelerator() +{ + return TRUE; +} + +/*! Not yet implemented +*/ + +bool RC2UI::makeCursor() +{ + return TRUE; +} + +/*! Not yet implemented +*/ + +bool RC2UI::makeHTML() +{ + return TRUE; +} + +/*! Not yet implemented +*/ + +bool RC2UI::makeIcon() +{ + return TRUE; +} + +/*! + Writes a stringtable from the input stream to a c++ header file. + All strings are assigned using QT_TR_NOOP to enable easy translation. +*/ + +bool RC2UI::makeStringTable() +{ + if ( !writeToFile ) + return TRUE; + + TQFile fileOut; + line = in->readLine(); + do { + char stringtable[256]; + char discard[12]; + sscanf( line, "%s %s", stringtable, discard ); + if ( TQString(stringtable) != "STRINGTABLE" ) + return TRUE; + do { + line = in->readLine(); + } while ( line != "BEGIN" ); + + TQString outputFile = TQString(stringtable).lower() + ".h"; + if (outputFile ) { + fileOut.setName( outputFile ); + if (!fileOut.open( IO_WriteOnly ) ) + qFatal( "rc2ui: Could not open output file '%s'", outputFile.latin1() ); + out = new TQTextStream( &fileOut ); + } + + *out << "#ifndef STRINGTABLE_H" << endl; + *out << "#define STRINGTABLE_H" << endl; + *out << endl; + *out << "#include <qstring.h>" << endl; + *out << "#include <qobject.h>" << endl; + *out << endl; + + TQString ID; + TQString value; + do { + line = in->readLine().stripWhiteSpace(); + if ( line == "END" ) + continue; + + ID = parseNext(line, ' '); + value = parseNext(line).stripWhiteSpace(); + + *out << "static const TQString " << ID << "= QT_TR_NOOP(" << value << ");" << endl; + + } while ( line != "END" ); + + *out << endl; + *out << "#endif // STRINGTABLE_H" << endl; + + do { + line = in->readLine(); + } while ( line.isEmpty() ); + + if ( out ) { + delete out; + out = 0; + } + } while ( line != blockStart1 ); + + return TRUE; +} + +/*! Not yet implemented +*/ + +bool RC2UI::makeVersion() +{ + return TRUE; +} diff --git a/tools/designer/plugins/rc/rc2ui.h b/tools/designer/plugins/rc/rc2ui.h new file mode 100644 index 000000000..e3cb11ae5 --- /dev/null +++ b/tools/designer/plugins/rc/rc2ui.h @@ -0,0 +1,103 @@ +/********************************************************************** +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef RC2UI_H +#define RC2UI_H + +#include <qtextstream.h> +#include <qfile.h> +#include <qstringlist.h> + +class RC2UI +{ +public: + RC2UI( TQTextStream* input ); + ~RC2UI(); + + bool parse(); + bool parse ( TQStringList& get ); + + TQStringList targetFiles; + +protected: + enum WidgetType { IDWidget, IDPushButton, IDLabel, IDCheckBox, IDRadioButton, + IDGroupBox, IDLineEdit, IDMultiLineEdit, IDIconView, IDListView, + IDProgressBar, IDTabWidget, IDSpinBox, IDSlider, IDComboBox, + IDListBox, IDScrollBar, IDCustom, IDUnknown = 0x0100 }; + bool makeDialog(); + bool makeBitmap(); + bool makeStringTable(); + bool makeAccelerator(); + bool makeCursor(); + bool makeHTML(); + bool makeIcon(); + bool makeVersion(); + + TQString line; + TQTextStream *in; + TQStringList target; + + void indent(); + void undent(); + + TQString stripQM( const TQString& string ); + TQString parseNext( TQString& arg, char sep = ',' ); + TQStringList splitStyles( const TQString& styles, char sep = '|' ); + void wi(); + + void writeClass( const TQString& name ); + void writeCString( const TQString& name, const TQString& value ); + void writeString( const TQString& name, const TQString& value ); + void writeRect( const TQString& name, int x, int y, int w, int h ); + void writeFont( const TQString& family, int pointsize ); + void writeBool( const TQString& name, bool value ); + void writeNumber( const TQString& name, int value ); + void writeEnum( const TQString& name, const TQString& value ); + void writeSet( const TQString& name, const TQString& value ); + + void writeStyles( const TQStringList styles, bool isFrame ); +private: + int indentation; + bool writeToFile; + TQTextStream* out; + + TQString useName( const TQString& ); + + TQStringList usedNames; + + const TQString blockStart1; + const TQString blockStart2; +}; + +#endif diff --git a/tools/designer/plugins/wizards/images/qtwizards_menu_1.png b/tools/designer/plugins/wizards/images/qtwizards_menu_1.png Binary files differnew file mode 100644 index 000000000..9a62ab905 --- /dev/null +++ b/tools/designer/plugins/wizards/images/qtwizards_menu_1.png diff --git a/tools/designer/plugins/wizards/images/qtwizards_menu_2.png b/tools/designer/plugins/wizards/images/qtwizards_menu_2.png Binary files differnew file mode 100644 index 000000000..fd5260745 --- /dev/null +++ b/tools/designer/plugins/wizards/images/qtwizards_menu_2.png diff --git a/tools/designer/plugins/wizards/images/qtwizards_menu_3.png b/tools/designer/plugins/wizards/images/qtwizards_menu_3.png Binary files differnew file mode 100644 index 000000000..7cf15ac5b --- /dev/null +++ b/tools/designer/plugins/wizards/images/qtwizards_menu_3.png diff --git a/tools/designer/plugins/wizards/images/qtwizards_table_1.png b/tools/designer/plugins/wizards/images/qtwizards_table_1.png Binary files differnew file mode 100644 index 000000000..425b133ea --- /dev/null +++ b/tools/designer/plugins/wizards/images/qtwizards_table_1.png diff --git a/tools/designer/plugins/wizards/images/qtwizards_table_2.png b/tools/designer/plugins/wizards/images/qtwizards_table_2.png Binary files differnew file mode 100644 index 000000000..f7295423c --- /dev/null +++ b/tools/designer/plugins/wizards/images/qtwizards_table_2.png diff --git a/tools/designer/plugins/wizards/images/qtwizards_table_3.png b/tools/designer/plugins/wizards/images/qtwizards_table_3.png Binary files differnew file mode 100644 index 000000000..472f26700 --- /dev/null +++ b/tools/designer/plugins/wizards/images/qtwizards_table_3.png diff --git a/tools/designer/plugins/wizards/images/qtwizards_table_4.png b/tools/designer/plugins/wizards/images/qtwizards_table_4.png Binary files differnew file mode 100644 index 000000000..493b12e7c --- /dev/null +++ b/tools/designer/plugins/wizards/images/qtwizards_table_4.png diff --git a/tools/designer/plugins/wizards/images/re-sort.png b/tools/designer/plugins/wizards/images/re-sort.png Binary files differnew file mode 100644 index 000000000..43a823499 --- /dev/null +++ b/tools/designer/plugins/wizards/images/re-sort.png diff --git a/tools/designer/plugins/wizards/images/small/editcopy.png b/tools/designer/plugins/wizards/images/small/editcopy.png Binary files differnew file mode 100644 index 000000000..080db0896 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/editcopy.png diff --git a/tools/designer/plugins/wizards/images/small/editcut.png b/tools/designer/plugins/wizards/images/small/editcut.png Binary files differnew file mode 100644 index 000000000..f8bd744f2 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/editcut.png diff --git a/tools/designer/plugins/wizards/images/small/editpaste.png b/tools/designer/plugins/wizards/images/small/editpaste.png Binary files differnew file mode 100644 index 000000000..dc7915e27 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/editpaste.png diff --git a/tools/designer/plugins/wizards/images/small/filenew.png b/tools/designer/plugins/wizards/images/small/filenew.png Binary files differnew file mode 100644 index 000000000..4e5a17233 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/filenew.png diff --git a/tools/designer/plugins/wizards/images/small/fileopen.png b/tools/designer/plugins/wizards/images/small/fileopen.png Binary files differnew file mode 100644 index 000000000..cb18a2c01 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/fileopen.png diff --git a/tools/designer/plugins/wizards/images/small/filesave.png b/tools/designer/plugins/wizards/images/small/filesave.png Binary files differnew file mode 100644 index 000000000..ad3f6f88a --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/filesave.png diff --git a/tools/designer/plugins/wizards/images/small/print.png b/tools/designer/plugins/wizards/images/small/print.png Binary files differnew file mode 100644 index 000000000..8a3640b62 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/print.png diff --git a/tools/designer/plugins/wizards/images/small/redo.png b/tools/designer/plugins/wizards/images/small/redo.png Binary files differnew file mode 100644 index 000000000..3a504a201 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/redo.png diff --git a/tools/designer/plugins/wizards/images/small/searchfind.png b/tools/designer/plugins/wizards/images/small/searchfind.png Binary files differnew file mode 100644 index 000000000..900156db5 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/searchfind.png diff --git a/tools/designer/plugins/wizards/images/small/undo.png b/tools/designer/plugins/wizards/images/small/undo.png Binary files differnew file mode 100644 index 000000000..2fc8d2697 --- /dev/null +++ b/tools/designer/plugins/wizards/images/small/undo.png diff --git a/tools/designer/plugins/wizards/main.cpp b/tools/designer/plugins/wizards/main.cpp new file mode 100644 index 000000000..0dbc5262a --- /dev/null +++ b/tools/designer/plugins/wizards/main.cpp @@ -0,0 +1,142 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include <designerinterface.h> +#include <qfeatures.h> +#include <qwidget.h> +#include <templatewizardiface.h> +#ifndef QT_NO_SQL +#include "sqlformwizardimpl.h" +#endif +#include "mainwindowwizard.h" +#include <qapplication.h> + +class StandardTemplateWizardInterface : public TemplateWizardInterface, public TQLibraryInterface +{ +public: + StandardTemplateWizardInterface(); + virtual ~StandardTemplateWizardInterface(); + + TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** ); + Q_REFCOUNT; + + TQStringList featureList() const; + + void setup( const TQString &templ, TQWidget *widget, DesignerFormWindow *fw, TQUnknownInterface *aIface ); + + bool init(); + void cleanup(); + bool canUnload() const; + +private: + bool inUse; +}; + +StandardTemplateWizardInterface::StandardTemplateWizardInterface() + : inUse( FALSE ) +{ +} + +StandardTemplateWizardInterface::~StandardTemplateWizardInterface() +{ +} + +bool StandardTemplateWizardInterface::init() +{ + return TRUE; +} + +void StandardTemplateWizardInterface::cleanup() +{ +} + +bool StandardTemplateWizardInterface::canUnload() const +{ + return !inUse; +} + +TQStringList StandardTemplateWizardInterface::featureList() const +{ + TQStringList list; +#ifndef QT_NO_SQL + list << "TQDataBrowser" << "TQDesignerDataBrowser" << "TQDataView" << \ + "TQDesignerDataView" << "TQDataTable"; +#endif + list << "TQMainWindow"; + + return list; +} + +void StandardTemplateWizardInterface::setup( const TQString &templ, TQWidget *widget, DesignerFormWindow *fw, TQUnknownInterface *aIface ) +{ + inUse = TRUE; +#ifndef QT_NO_SQL + if ( templ == "TQDesignerDataView" || + templ == "TQDesignerDataBrowser" || + templ == "TQDataView" || + templ == "TQDataBrowser" || + templ == "TQDataTable" ) { + SqlFormWizard wizard( aIface, widget, qApp->mainWidget(), fw, 0, TRUE ); + wizard.exec(); + } +#endif + if ( templ == "TQMainWindow" ) { + MainWindowWizardBase wizard( qApp->mainWidget(), 0, TRUE ); + wizard.setAppInterface( aIface, fw, widget ); + wizard.exec(); + } + inUse = FALSE; +} + +TQRESULT StandardTemplateWizardInterface::queryInterface( const TQUuid& uuid, TQUnknownInterface** iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)(TemplateWizardInterface*) this; + else if ( uuid == IID_QFeatureList ) + *iface = (TQFeatureListInterface*)this; + else if ( uuid == IID_TemplateWizard ) + *iface = (TemplateWizardInterface*)this; + else if ( uuid == IID_QLibrary ) + *iface = (TQLibraryInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +Q_EXPORT_COMPONENT() +{ + Q_CREATE_INSTANCE( StandardTemplateWizardInterface ) +} diff --git a/tools/designer/plugins/wizards/mainwindowwizard.ui b/tools/designer/plugins/wizards/mainwindowwizard.ui new file mode 100644 index 000000000..cdb8f59de --- /dev/null +++ b/tools/designer/plugins/wizards/mainwindowwizard.ui @@ -0,0 +1,757 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>MainWindowWizardBase</class> +<comment>********************************************************************* +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +*********************************************************************</comment> +<include location="global" impldecl="in implementation">designerinterface.h</include> +<include location="global" impldecl="in implementation">qiconset.h</include> +<include location="global" impldecl="in implementation">qaction.h</include> +<include location="global" impldecl="in implementation">qpixmap.h</include> +<include location="global" impldecl="in implementation">qdict.h</include> +<include location="local" implDecl="in declaration">mainwindowwizard.ui.h</include> +<forward>struct DesignerFormWindow;</forward> +<forward>struct DesignerInterface;</forward> +<forward>struct TQUnknownInterface;</forward> +<forward>class TQWidget;</forward> +<variable>TQWidget *widget;</variable> +<variable>DesignerInterface *dIface;</variable> +<variable>DesignerFormWindow *dfw;</variable> +<pixmapinproject/> +<layoutdefaults spacing="6" margin="11"/> +<widget class="TQWizard"> + <property name="name"> + <cstring>MainWindowWizardBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>604</width> + <height>392</height> + </rect> + </property> + <property name="caption"> + <string>Main Window Wizard</string> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>menuToolbarPage</cstring> + </property> + <attribute name="title"> + <string>Choose available menus and toolbars</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <spacer row="4" column="1"> + <property name="name"> + <cstring>Spacer7</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQLabel" row="0" column="0" rowspan="5" colspan="1"> + <property name="name"> + <cstring>TextLabel4_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_menu_1.png</pixmap> + </property> + </widget> + <widget class="TQGroupBox" row="1" column="1"> + <property name="name"> + <cstring>GroupBox1</cstring> + </property> + <property name="title"> + <string>File Actions</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkFileMenu</cstring> + </property> + <property name="text"> + <string>Menu</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="1"> + <property name="name"> + <cstring>checkFileToolbar</cstring> + </property> + <property name="text"> + <string>Toolbar</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <spacer row="1" column="2"> + <property name="name"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQCheckBox" row="1" column="3"> + <property name="name"> + <cstring>checkCreateConnectionsFile</cstring> + </property> + <property name="text"> + <string>Create Slots and Connections for the actions</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQLabel" row="0" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>like New, Open File, Save, Print, etc.</string> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="2" column="1"> + <property name="name"> + <cstring>GroupBox2</cstring> + </property> + <property name="title"> + <string>Edit Actions</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQCheckBox" row="1" column="1"> + <property name="name"> + <cstring>checkEditToolbar</cstring> + </property> + <property name="text"> + <string>Toolbar</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkEditMenu</cstring> + </property> + <property name="text"> + <string>Menu</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <spacer row="1" column="2"> + <property name="name"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQCheckBox" row="1" column="3"> + <property name="name"> + <cstring>checkCreateConnectionsEdit</cstring> + </property> + <property name="text"> + <string>Create Slots and Connections for the actions</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQLabel" row="0" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>TextLabel2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>like Cut, Copy, Paste, Undo and Redo, etc.</string> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="3" column="1"> + <property name="name"> + <cstring>GroupBox3</cstring> + </property> + <property name="title"> + <string>Help Actions</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="0" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>TextLabel2_2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>like Contents and About, etc.</string> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkHelpMenu</cstring> + </property> + <property name="text"> + <string>Menu</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="1"> + <property name="name"> + <cstring>checkHelpToolbar</cstring> + </property> + <property name="text"> + <string>Toolbar</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <spacer row="1" column="2"> + <property name="name"> + <cstring>Spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQCheckBox" row="1" column="3"> + <property name="name"> + <cstring>checkCreateConnectionsHelp</cstring> + </property> + <property name="text"> + <string>Create Slots and Connections for the actions</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>toolbarsPage</cstring> + </property> + <attribute name="title"> + <string>Setup Toolbar</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQPushButton" row="7" column="2"> + <property name="name"> + <cstring>buttonToolbarActionUp</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_up.png</pixmap> + </property> + </widget> + <widget class="TQLabel" row="2" column="3"> + <property name="name"> + <cstring>TextLabel4_3_2</cstring> + </property> + <property name="text"> + <string>&Toolbar</string> + </property> + <property name="buddy" stdset="0"> + <cstring>listToolbar</cstring> + </property> + </widget> + <widget class="TQPushButton" row="8" column="2"> + <property name="name"> + <cstring>buttonToolbarActionDown</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_down.png</pixmap> + </property> + </widget> + <widget class="TQListBox" row="3" column="1" rowspan="7" colspan="1"> + <property name="name"> + <cstring>listToolbarActions</cstring> + </property> + </widget> + <widget class="TQListBox" row="3" column="3" rowspan="7" colspan="1"> + <property name="name"> + <cstring>listToolbar</cstring> + </property> + </widget> + <widget class="TQLayoutWidget" row="1" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>Layout20_2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel5_2</cstring> + </property> + <property name="text"> + <string>&Category</string> + </property> + <property name="buddy" stdset="0"> + <cstring>comboToolbar</cstring> + </property> + </widget> + <widget class="TQComboBox"> + <property name="name"> + <cstring>comboToolbar</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="TQLabel" row="2" column="1"> + <property name="name"> + <cstring>TextLabel4_4</cstring> + </property> + <property name="text"> + <string>&Actions</string> + </property> + <property name="buddy" stdset="0"> + <cstring>listToolbarActions</cstring> + </property> + </widget> + <widget class="TQPushButton" row="5" column="2"> + <property name="name"> + <cstring>buttonToolbarRemoveAction</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_left.png</pixmap> + </property> + </widget> + <widget class="TQLabel" row="0" column="0" rowspan="10" colspan="1"> + <property name="name"> + <cstring>TextLabel4_2_2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_menu_2.png</pixmap> + </property> + </widget> + <widget class="TQPushButton" row="4" column="2"> + <property name="name"> + <cstring>buttonToolbarAddAction</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_right.png</pixmap> + </property> + </widget> + <spacer row="3" column="2"> + <property name="name"> + <cstring>Spacer11</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="6" column="2"> + <property name="name"> + <cstring>Spacer12</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="9" column="2"> + <property name="name"> + <cstring>Spacer13</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>finishPage</cstring> + </property> + <attribute name="title"> + <string>Finish</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="0" column="0" rowspan="3" colspan="1"> + <property name="name"> + <cstring>TextLabel4_2_2_2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_menu_3.png</pixmap> + </property> + </widget> + <widget class="TQLabel" row="1" column="1"> + <property name="name"> + <cstring>TextLabel1_5</cstring> + </property> + <property name="text"> + <string>Press Finish to populate the main window.</string> + </property> + </widget> + <spacer row="0" column="1"> + <property name="name"> + <cstring>Spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="2" column="1"> + <property name="name"> + <cstring>Spacer1_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> +</widget> +<connections> + <connection language="C++"> + <sender>comboToolbar</sender> + <signal>activated(const TQString&)</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>currentToolbarChanged(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>buttonToolbarAddAction</sender> + <signal>clicked()</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>toolbarAddAction()</slot> + </connection> + <connection language="C++"> + <sender>buttonToolbarRemoveAction</sender> + <signal>clicked()</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>toolbarRemoveAction()</slot> + </connection> + <connection language="C++"> + <sender>buttonToolbarActionUp</sender> + <signal>clicked()</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>toolbarActionUp()</slot> + </connection> + <connection language="C++"> + <sender>buttonToolbarActionDown</sender> + <signal>clicked()</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>toolbarActionDown()</slot> + </connection> + <connection language="C++"> + <sender>MainWindowWizardBase</sender> + <signal>selected(const TQString&)</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>pageSelected(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>checkHelpMenu</sender> + <signal>toggled(bool)</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>currentSettingChanged()</slot> + </connection> + <connection language="C++"> + <sender>checkHelpToolbar</sender> + <signal>toggled(bool)</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>currentSettingChanged()</slot> + </connection> + <connection language="C++"> + <sender>checkEditMenu</sender> + <signal>toggled(bool)</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>currentSettingChanged()</slot> + </connection> + <connection language="C++"> + <sender>checkEditToolbar</sender> + <signal>toggled(bool)</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>currentSettingChanged()</slot> + </connection> + <connection language="C++"> + <sender>checkFileMenu</sender> + <signal>toggled(bool)</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>currentSettingChanged()</slot> + </connection> + <connection language="C++"> + <sender>checkFileToolbar</sender> + <signal>toggled(bool)</signal> + <receiver>MainWindowWizardBase</receiver> + <slot>currentSettingChanged()</slot> + </connection> + <slot access="protected" specifier="virtual" language="C++" returnType="void">init()</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">destroy()</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">currentSettingChanged()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">setupToolbarPage()</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">toolbarActionDown()</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">toolbarActionUp()</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">toolbarAddAction()</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">toolbarRemoveAction()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">accept()</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">currentToolbarChanged( const TQString & s )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">getPixmap( const TQString & n, TQPixmap & pix )</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">pageSelected( const TQString & )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">setAppInterface( TQUnknownInterface * iface, DesignerFormWindow * fw, TQWidget * w )</slot> +</connections> +<tabstops> + <tabstop>checkFileMenu</tabstop> + <tabstop>checkFileToolbar</tabstop> + <tabstop>checkEditMenu</tabstop> + <tabstop>checkEditToolbar</tabstop> + <tabstop>checkHelpMenu</tabstop> + <tabstop>checkHelpToolbar</tabstop> + <tabstop>comboToolbar</tabstop> + <tabstop>listToolbarActions</tabstop> + <tabstop>buttonToolbarAddAction</tabstop> + <tabstop>buttonToolbarRemoveAction</tabstop> + <tabstop>buttonToolbarActionUp</tabstop> + <tabstop>buttonToolbarActionDown</tabstop> + <tabstop>listToolbar</tabstop> +</tabstops> +</UI> diff --git a/tools/designer/plugins/wizards/mainwindowwizard.ui.h b/tools/designer/plugins/wizards/mainwindowwizard.ui.h new file mode 100644 index 000000000..fa491b5e3 --- /dev/null +++ b/tools/designer/plugins/wizards/mainwindowwizard.ui.h @@ -0,0 +1,321 @@ +/********************************************************************** +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +void MainWindowWizardBase::init() +{ + dIface = 0; + dfw = 0; + widget = 0; + setHelpEnabled( menuToolbarPage, FALSE ); + setHelpEnabled( toolbarsPage, FALSE ); + setHelpEnabled( finishPage, FALSE ); + setFinishEnabled( finishPage, TRUE ); +} + +void MainWindowWizardBase::destroy() +{ + if ( dIface ) + dIface->release(); +} + +void MainWindowWizardBase::currentSettingChanged() +{ + bool appr = checkFileToolbar->isChecked() || checkEditToolbar->isChecked() || checkHelpToolbar->isChecked(); + setAppropriate( toolbarsPage, appr ); +} + +void MainWindowWizardBase::setupToolbarPage() +{ + if ( checkFileToolbar->isChecked() ) + comboToolbar->insertItem( tr( "File" ) ); + if ( checkEditToolbar->isChecked() ) + comboToolbar->insertItem( tr( "Edit" ) ); + if ( checkHelpToolbar->isChecked() ) + comboToolbar->insertItem( tr( "Help" ) ); +} + +void MainWindowWizardBase::toolbarActionDown() +{ + if ( listToolbar->currentItem() < 0 || listToolbar->currentItem() >= (int)listToolbar->count() - 1 ) + return; + + int next = listToolbar->currentItem() + 1; + TQString tmp = listToolbar->text( next ); + listToolbar->changeItem( listToolbar->text( next - 1 ), next ); + listToolbar->changeItem( tmp, next - 1 ); + listToolbar->setCurrentItem( next ); +} + +void MainWindowWizardBase::toolbarActionUp() +{ + if ( listToolbar->currentItem() < 1 || listToolbar->currentItem() > (int)listToolbar->count() - 1 ) + return; + + int prev = listToolbar->currentItem() - 1; + TQString tmp = listToolbar->text( prev ); + listToolbar->changeItem( listToolbar->text( prev + 1 ), prev ); + listToolbar->changeItem( tmp, prev + 1 ); + listToolbar->setCurrentItem( prev ); +} + +void MainWindowWizardBase::toolbarAddAction() +{ + if ( listToolbarActions->text( listToolbarActions->currentItem() ).isEmpty() ) + return; + listToolbar->insertItem( listToolbarActions->text( listToolbarActions->currentItem() ) ); + listToolbar->setCurrentItem( listToolbar->count() - 1 ); + listToolbarActions->setCurrentItem( listToolbarActions->currentItem() + 1 ); +} + +void MainWindowWizardBase::toolbarRemoveAction() +{ + listToolbar->removeItem( listToolbar->currentItem() ); +} + +static void devNull( TQtMsgType, const char * ) +{ +} + +void MainWindowWizardBase::accept() +{ + if ( !dfw || !dIface || !widget ) { + TQWizard::accept(); + return; + } + + setFinishEnabled( finishPage, FALSE ); + + TQPixmap pix; + + TQDict<TQAction> actions; + TQPtrList<TQAction> usedActions; + + TQtMsgHandler oldMsgHandler = qInstallMsgHandler( devNull ); + + getPixmap( "filenew", pix ); + + TQAction *fileNewAction = dfw->createAction( tr( "New" ), pix, tr( "&New" ), CTRL + Key_N, 0, "fileNewAction" ); + actions.insert( tr( "New" ), fileNewAction ); + getPixmap( "fileopen", pix ); + TQAction *fileOpenAction = dfw->createAction( tr( "Open" ), pix, tr( "&Open..." ), CTRL + Key_O, 0, "fileOpenAction" ); + actions.insert( tr( "Open" ), fileOpenAction ); + getPixmap( "filesave", pix ); + TQAction *fileSaveAction = dfw->createAction( tr( "Save" ), pix, tr( "&Save" ), CTRL + Key_S, 0, "fileSaveAction" ); + actions.insert( tr( "Save" ), fileSaveAction ); + TQAction *fileSaveAsAction = dfw->createAction( tr( "Save As" ), TQIconSet(), tr( "Save &As..." ), 0, 0, "fileSaveAsAction" ); + actions.insert( tr( "Save As" ), fileSaveAsAction ); + getPixmap( "print", pix ); + TQAction *filePrintAction = dfw->createAction( tr( "Print" ), pix, tr( "&Print..." ), CTRL + Key_P, 0, "filePrintAction" ); + actions.insert( tr( "Print" ), filePrintAction ); + TQAction *fileExitAction = dfw->createAction( tr( "Exit" ), TQIconSet(), tr( "E&xit" ), 0, 0, "fileExitAction" ); + actions.insert( tr( "Exit" ), fileExitAction ); + + getPixmap( "undo", pix ); + TQAction *editUndoAction = dfw->createAction( tr( "Undo" ), pix, tr( "&Undo" ), CTRL + Key_Z, 0, "editUndoAction" ); + actions.insert( tr( "Undo" ), editUndoAction ); + getPixmap( "redo", pix ); + TQAction *editRedoAction = dfw->createAction( tr( "Redo" ), pix, tr( "&Redo" ), CTRL + Key_Y, 0, "editRedoAction" ); + actions.insert( tr( "Redo" ), editRedoAction ); + getPixmap( "editcut", pix ); + TQAction *editCutAction = dfw->createAction( tr( "Cut" ), pix, tr( "Cu&t" ), CTRL + Key_X, 0, "editCutAction" ); + actions.insert( tr( "Cut" ), editCutAction ); + getPixmap( "editcopy", pix ); + TQAction *editCopyAction = dfw->createAction( tr( "Copy" ), pix, tr( "&Copy" ), CTRL + Key_C, 0, "editCopyAction" ); + actions.insert( tr( "Copy" ), editCopyAction ); + getPixmap( "editpaste", pix ); + TQAction *editPasteAction = dfw->createAction( tr( "Paste" ), pix, tr( "&Paste" ), CTRL + Key_V, 0, "editPasteAction" ); + actions.insert( tr( "Paste" ), editPasteAction ); + getPixmap( "searchfind", pix ); + TQAction *editFindAction = dfw->createAction( tr( "Find" ), pix, tr( "&Find..." ), CTRL + Key_F, 0, "editFindAction" ); + actions.insert( tr( "Find" ), editFindAction ); + + TQAction *helpAboutAction = dfw->createAction( tr( "About" ), TQIconSet(), tr( "&About" ), 0, 0, "helpAboutAction" ); + actions.insert( tr( "About" ), helpAboutAction ); + TQAction *helpContentsAction = dfw->createAction( tr( "Contents" ), TQIconSet(), tr( "&Contents..." ), 0, 0, "helpContentsAction" ); + actions.insert( tr( "Contents" ), helpContentsAction ); + TQAction *helpIndexAction = dfw->createAction( tr( "Index" ), TQIconSet(), tr( "&Index..." ), 0, 0, "helpIndexAction" ); + actions.insert( tr( "Index" ), helpIndexAction ); + + if ( checkFileMenu->isChecked() ) { + dfw->addMenu( "&File", "fileMenu" ); + dfw->addMenuAction( "fileMenu", fileNewAction ); + dfw->addMenuAction( "fileMenu", fileOpenAction ); + dfw->addMenuAction( "fileMenu", fileSaveAction ); + dfw->addMenuAction( "fileMenu", fileSaveAsAction ); + dfw->addMenuSeparator( "fileMenu" ); + dfw->addMenuAction( "fileMenu", filePrintAction ); + dfw->addMenuSeparator( "fileMenu" ); + dfw->addMenuAction( "fileMenu", fileExitAction ); + dfw->addAction( fileNewAction ); + dfw->addAction( fileOpenAction ); + dfw->addAction( fileSaveAction ); + dfw->addAction( fileSaveAsAction ); + dfw->addAction( filePrintAction ); + dfw->addAction( fileExitAction ); + usedActions.append( fileNewAction ); + usedActions.append( fileOpenAction ); + usedActions.append( fileSaveAction ); + usedActions.append( fileSaveAsAction ); + usedActions.append( filePrintAction ); + usedActions.append( fileExitAction ); + } + + if ( checkEditMenu->isChecked() ) { + dfw->addMenu( "&Edit", "editMenu" ); + dfw->addMenuAction( "editMenu", editUndoAction ); + dfw->addMenuAction( "editMenu", editRedoAction ); + dfw->addMenuSeparator( "editMenu" ); + dfw->addMenuAction( "editMenu", editCutAction ); + dfw->addMenuAction( "editMenu", editCopyAction ); + dfw->addMenuAction( "editMenu", editPasteAction ); + dfw->addMenuSeparator( "editMenu" ); + dfw->addMenuAction( "editMenu", editFindAction ); + dfw->addAction( editUndoAction ); + dfw->addAction( editRedoAction ); + dfw->addAction( editCutAction ); + dfw->addAction( editCopyAction ); + dfw->addAction( editPasteAction ); + dfw->addAction( editFindAction ); + usedActions.append( editUndoAction ); + usedActions.append( editRedoAction ); + usedActions.append( editCutAction ); + usedActions.append( editCopyAction ); + usedActions.append( editPasteAction ); + usedActions.append( editFindAction ); + } + + if ( checkHelpMenu->isChecked() ) { + dfw->addMenu( "&Help", "helpMenu" ); + dfw->addMenuAction( "helpMenu", helpContentsAction ); + dfw->addMenuAction( "helpMenu", helpIndexAction ); + dfw->addMenuSeparator( "helpMenu" ); + dfw->addMenuAction( "helpMenu", helpAboutAction ); + dfw->addAction( helpContentsAction ); + dfw->addAction( helpIndexAction ); + dfw->addAction( helpAboutAction ); + usedActions.append( helpIndexAction ); + usedActions.append( helpContentsAction ); + usedActions.append( helpAboutAction ); + } + + if ( listToolbar->count() > 0 && appropriate( toolbarsPage ) ) { + dfw->addToolBar( "Tools", "toolBar" ); + for ( int i = 0; i < (int)listToolbar->count(); ++i ) { + if ( listToolbar->text( i ) == tr( "<Separator>" ) ) { + dfw->addToolBarSeparator( "toolBar" ); + continue; + } + TQAction *a = actions.find( listToolbar->text( i ) ); + if ( !a ) + continue; + dfw->addToolBarAction( "toolBar", a ); + dfw->addAction( a ); + if ( usedActions.findRef( a ) == -1 ) + usedActions.append( a ); + } + } + for ( TQAction *ac = usedActions.first(); ac; ac = usedActions.next() ) { + if ( TQString( ac->name() ).find( "file" ) != -1 && checkCreateConnectionsFile->isChecked() || + TQString( ac->name() ).find( "edit" ) != -1 && checkCreateConnectionsEdit->isChecked() || + TQString( ac->name() ).find( "help" ) != -1 && checkCreateConnectionsHelp->isChecked() ) { + TQString slot = ac->name(); + slot.remove( slot.length() - 6, 6 ); + slot += "()"; + dfw->addFunction( slot.latin1(), "virtual", "public", "slot", dIface->currentProject()->language(), "void" ); + dfw->addConnection( ac, "activated()", widget, slot ); + } + } + + qInstallMsgHandler( oldMsgHandler ); + + TQWizard::accept(); +} + +void MainWindowWizardBase::currentToolbarChanged( const TQString & s ) +{ + if ( s == tr( "File" ) ) { + listToolbarActions->clear(); + listToolbarActions->insertItem( tr( "New" ) ); + listToolbarActions->insertItem( tr( "Open" ) ); + listToolbarActions->insertItem( tr( "Save" ) ); + listToolbarActions->insertItem( tr( "Save As" ) ); + listToolbarActions->insertItem( tr( "Print" ) ); + listToolbarActions->insertItem( tr( "Exit" ) ); + } else if ( s == tr( "Edit" ) ) { + listToolbarActions->clear(); + listToolbarActions->insertItem( tr( "Undo" ) ); + listToolbarActions->insertItem( tr( "Redo" ) ); + listToolbarActions->insertItem( tr( "Cut" ) ); + listToolbarActions->insertItem( tr( "Copy" ) ); + listToolbarActions->insertItem( tr( "Paste" ) ); + listToolbarActions->insertItem( tr( "Find" ) ); + } else if ( s == tr( "Help" ) ) { + listToolbarActions->clear(); + listToolbarActions->insertItem( tr( "Contents" ) ); + listToolbarActions->insertItem( tr( "Index" ) ); + listToolbarActions->insertItem( tr( "About" ) ); + } + listToolbarActions->insertItem( "<Separator>" ); + listToolbarActions->setCurrentItem( 0 ); +} + +void MainWindowWizardBase::getPixmap( const TQString & n, TQPixmap & pix ) +{ + TQString name = n + ".png"; + pix = TQPixmap::fromMimeSource( name ); + DesignerProject *pro = dIface->currentProject(); + if ( !pro || pro->projectName() == "<No Project>" ) + return; + pro->pixmapCollection()->addPixmap( pix, n, FALSE ); +} + +void MainWindowWizardBase::pageSelected( const TQString & ) +{ + if ( currentPage() == toolbarsPage ) { + comboToolbar->clear(); + setupToolbarPage(); + listToolbarActions->clear(); + currentToolbarChanged( comboToolbar->text( comboToolbar->currentItem() ) ); + } +} + +void MainWindowWizardBase::setAppInterface( TQUnknownInterface * iface, DesignerFormWindow * fw, TQWidget * w ) +{ + DesignerInterface *d = 0; + iface->queryInterface( IID_Designer, (TQUnknownInterface**)&d ); + dIface = d; + dfw = fw; + widget = w; +} + diff --git a/tools/designer/plugins/wizards/sqlformwizard.ui b/tools/designer/plugins/wizards/sqlformwizard.ui new file mode 100644 index 000000000..fee38f7a9 --- /dev/null +++ b/tools/designer/plugins/wizards/sqlformwizard.ui @@ -0,0 +1,1776 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>SqlFormWizardBase</class> +<comment>********************************************************************* +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +*********************************************************************</comment> +<widget class="TQWizard"> + <property name="name"> + <cstring>SqlFormWizardBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>577</width> + <height>570</height> + </rect> + </property> + <property name="caption"> + <string>Sql Wizard</string> + </property> + <property name="icon"> + <pixmap></pixmap> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>databasePage</cstring> + </property> + <attribute name="title"> + <string>Choose the Database and Table</string> + </attribute> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_table_1.png</pixmap> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>Layout5</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="1" column="1"> + <property name="name"> + <cstring>TextLabel3_2</cstring> + </property> + <property name="text"> + <string>&Table:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>listBoxTable</cstring> + </property> + </widget> + <widget class="TQLayoutWidget" row="4" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>Layout4</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQPushButton"> + <property name="name"> + <cstring>PushButton5</cstring> + </property> + <property name="text"> + <string>&Setup Database Connections...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Click here to manage your database connections</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Here you can add, modify and delete your database connections</string> + </property> + </widget> + <spacer> + <property name="name" stdset="0"> + <cstring>Spacer1_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>TextLabel3_3</cstring> + </property> + <property name="text"> + <string>Database &Connection:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>listBoxConnection</cstring> + </property> + </widget> + <widget class="TQListBox" row="2" column="1"> + <property name="name"> + <cstring>listBoxTable</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Displays all tables inside the selected Database</string> + </property> + </widget> + <widget class="TQListBox" row="2" column="0"> + <property name="name"> + <cstring>listBoxConnection</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Displays a list of available connections on your system</string> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>populatePage</cstring> + </property> + <attribute name="title"> + <string>Displayed Fields</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="0" column="0" rowspan="2" colspan="1"> + <property name="name"> + <cstring>TextLabel4_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_table_2.png</pixmap> + </property> + </widget> + <widget class="TQLayoutWidget" row="1" column="1"> + <property name="name"> + <cstring>Layout11</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <spacer row="4" column="1"> + <property name="name" stdset="0"> + <cstring>Spacer1_10</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQPushButton" row="2" column="1"> + <property name="name"> + <cstring>buttonAddField_2</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_right.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>Move field to list of displayed fields</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to add the selected field to the list of fields that will be displayed.</string> + </property> + </widget> + <widget class="TQPushButton" row="3" column="1"> + <property name="name"> + <cstring>buttonRemoveField_2</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_left.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>remove field from list of displayed fields</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to remove the selected field from the list of fields that will be displayed.</string> + </property> + </widget> + <spacer row="1" column="1"> + <property name="name" stdset="0"> + <cstring>Spacer2_5</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQPushButton" row="5" column="1"> + <property name="name"> + <cstring>buttonFieldUp_2</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_up.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>Move Field up</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to move the selected field in the displayed fields list up.</string> + </property> + </widget> + <spacer row="7" column="1"> + <property name="name" stdset="0"> + <cstring>Spacer3_3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQListBox" row="1" column="0" rowspan="7" colspan="1"> + <property name="name"> + <cstring>listBoxField</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>This is a list of all available fields in your selected table. Fields in this list will not be displayed.</string> + </property> + </widget> + <widget class="TQPushButton" row="6" column="1"> + <property name="name"> + <cstring>buttonFieldDown_2</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_down.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>Move field down</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to move the selected field in the displayed fields list down.</string> + </property> + </widget> + <widget class="TQListBox" row="1" column="2" rowspan="7" colspan="1"> + <property name="name"> + <cstring>listBoxSelectedField</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>All fields in this list will be displayed.</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="2"> + <property name="name"> + <cstring>TextLabel2_3</cstring> + </property> + <property name="text"> + <string>Displayed Fields:</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>TextLabel1_7</cstring> + </property> + <property name="text"> + <string>Available Fields:</string> + </property> + </widget> + </grid> + </widget> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>navigPage</cstring> + </property> + <attribute name="title"> + <string>Navigation and Editing</string> + </attribute> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel4_2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_table_3.png</pixmap> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>Layout6</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQCheckBox"> + <property name="name"> + <cstring>checkBoxNavig</cstring> + </property> + <property name="text"> + <string>&Include Navigation Buttons</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Activates the navigation bar</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Activates the navigation bar</string> + </property> + </widget> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>GroupBox2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>&Navigation</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQCheckBox" row="0" column="0"> + <property name="name"> + <cstring>checkBoxPrev</cstring> + </property> + <property name="text"> + <string>&Previous</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Toggles whether the "Previous" button will be displayed</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Toggles whether the "Previous" button will be displayed</string> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkBoxNext</cstring> + </property> + <property name="text"> + <string>&Next</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Toggles whether the "Next" button will be displayed</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Toggles whether the "Next" button will be displayed</string> + </property> + </widget> + <widget class="TQCheckBox" row="0" column="1"> + <property name="name"> + <cstring>checkBoxFirst</cstring> + </property> + <property name="text"> + <string>&First</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Toggles whether the "First" button will be displayed</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Toggles whether the "First" button will be displayed</string> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="1"> + <property name="name"> + <cstring>checkBoxLast</cstring> + </property> + <property name="text"> + <string>&Last</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Toggles whether the "Last" button will be displayed</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Toggles whether the "Last" button will be displayed</string> + </property> + </widget> + </grid> + </widget> + <widget class="TQCheckBox"> + <property name="name"> + <cstring>checkBoxEdit</cstring> + </property> + <property name="text"> + <string>In&clude Edit Buttons</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Activates the edit bar</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Activates the edit bar</string> + </property> + </widget> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>GroupBox3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>&Editing</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQCheckBox" row="0" column="0"> + <property name="name"> + <cstring>checkBoxInsert</cstring> + </property> + <property name="text"> + <string>&Insert</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>User can insert new rows</string> + </property> + <property name="whatsThis" stdset="0"> + <string>User can insert new rows</string> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkBoxUpdate</cstring> + </property> + <property name="text"> + <string>&Update</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>user can edit existing rows</string> + </property> + <property name="whatsThis" stdset="0"> + <string>user can edit existing rows</string> + </property> + </widget> + <widget class="TQCheckBox" row="0" column="1"> + <property name="name"> + <cstring>checkBoxDelete</cstring> + </property> + <property name="text"> + <string>&Delete</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>user can delete rows</string> + </property> + <property name="whatsThis" stdset="0"> + <string>user can delete rows</string> + </property> + </widget> + </grid> + </widget> + <spacer> + <property name="name" stdset="0"> + <cstring>Spacer1_3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> + </widget> + </hbox> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>tablePropertiesPage</cstring> + </property> + <attribute name="title"> + <string>Table Properties</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="0" column="0" rowspan="4" colspan="1"> + <property name="name"> + <cstring>TextLabel4_2_2_2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_table_4.png</pixmap> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name" stdset="0"> + <cstring>Spacer1_7</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQGroupBox" row="1" column="1"> + <property name="name"> + <cstring>GroupBox5</cstring> + </property> + <property name="title"> + <string>Editing</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQCheckBox"> + <property name="name"> + <cstring>checkBoxReadOnly</cstring> + </property> + <property name="text"> + <string>&Read-Only</string> + </property> + <property name="toolTip" stdset="0"> + <string>Table will be read-only</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Activate this to prevent editing, deleting and adding of rows</string> + </property> + </widget> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>GroupBox4</cstring> + </property> + <property name="title"> + <string>Confirmations</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQCheckBox" row="0" column="0"> + <property name="name"> + <cstring>checkBoxConfirmInserts</cstring> + </property> + <property name="text"> + <string>Confirm &Inserts</string> + </property> + <property name="toolTip" stdset="0"> + <string>Query user on inserting rows</string> + </property> + <property name="whatsThis" stdset="0"> + <string>User will be asked for confirmation if he inserts a new row</string> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkBoxConfirmUpdates</cstring> + </property> + <property name="text"> + <string>Confirm &Updates</string> + </property> + <property name="toolTip" stdset="0"> + <string>Query user on editing rows</string> + </property> + <property name="whatsThis" stdset="0"> + <string>User will be asked for confirmation if he edits a row</string> + </property> + </widget> + <widget class="TQCheckBox" row="3" column="0"> + <property name="name"> + <cstring>checkBoxConfirmCancels</cstring> + </property> + <property name="text"> + <string>Confirm &Cancels</string> + </property> + <property name="toolTip" stdset="0"> + <string>Query user on canceling</string> + </property> + <property name="whatsThis" stdset="0"> + <string>User will be asked for confirmation if he cancels an action</string> + </property> + </widget> + <widget class="TQCheckBox" row="2" column="0"> + <property name="name"> + <cstring>checkBoxConfirmDeletes</cstring> + </property> + <property name="text"> + <string>Confirm &Deletes</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Query user on deleting rows</string> + </property> + <property name="whatsThis" stdset="0"> + <string>User will be asked for confirmation if he deletes a row</string> + </property> + </widget> + </grid> + </widget> + </vbox> + </widget> + <widget class="TQCheckBox" row="2" column="1"> + <property name="name"> + <cstring>checkBoxSorting</cstring> + </property> + <property name="text"> + <string>Allow column &sorting</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>User may change sorting</string> + </property> + <property name="whatsThis" stdset="0"> + <string>User may change sorting of data by clicking on a field in the top row of the table</string> + </property> + </widget> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>sqlPage</cstring> + </property> + <attribute name="title"> + <string>SQL</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="0" column="0" rowspan="2" colspan="1"> + <property name="name"> + <cstring>TextLabel4_2_2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_table_2.png</pixmap> + </property> + </widget> + <widget class="TQLayoutWidget" row="1" column="1"> + <property name="name"> + <cstring>Layout8</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel3_2_2_2</cstring> + </property> + <property name="text"> + <string>&Sort:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>listBoxTable</cstring> + </property> + </widget> + <spacer> + <property name="name" stdset="0"> + <cstring>Spacer1_5</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <widget class="TQLayoutWidget" row="0" column="1"> + <property name="name"> + <cstring>Layout10</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel3_2_2</cstring> + </property> + <property name="text"> + <string>&Filter:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>listBoxTable</cstring> + </property> + </widget> + <spacer> + <property name="name" stdset="0"> + <cstring>Spacer1_4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <widget class="TQLayoutWidget" row="0" column="2" rowspan="1" colspan="3"> + <property name="name"> + <cstring>Layout13</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel1_3</cstring> + </property> + <property name="text"> + <string>(a valid WHERE clause, e.g. id > 100)</string> + </property> + </widget> + <widget class="TQMultiLineEdit"> + <property name="name"> + <cstring>editFilter</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter a valid SQL WHERE statement, for example: +name like "qt%" +(name like "q%") and (version > 3) +((version > 3) and (price > 1000)) or (name like "%embed%")</string> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget" row="1" column="4"> + <property name="name"> + <cstring>Layout10</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>Sort By</string> + </property> + </widget> + <widget class="TQListBox"> + <property name="name"> + <cstring>listBoxSortedField</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Data will be sorted according to the selected fields.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget" row="1" column="3"> + <property name="name"> + <cstring>Layout11</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <spacer> + <property name="name" stdset="0"> + <cstring>Spacer2_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonAddSortField</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_right.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>Move field to the right list</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Klick here to add the currently selected field from the available fields list to the sorting criteria</string> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonRemoveSortField</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_left.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>remove field from the right list</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Klick here to remove the currently selected field from the sorting criteria</string> + </property> + </widget> + <spacer> + <property name="name" stdset="0"> + <cstring>Spacer1_6</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonUpSortField</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_up.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>move field up</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Move selected field in the sort by list up</string> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonDownSortField</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>designer_down.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>move field down</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Move selected field in the sort by list down</string> + </property> + </widget> + <spacer> + <property name="name" stdset="0"> + <cstring>Spacer2_3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonReSortField</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>re-sort.png</pixmap> + </property> + <property name="toolTip" stdset="0"> + <string>Change field sort from ASC to DESC and back</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Changes the field sort order from ascending to descending for the selected field in the sort by list.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget" row="1" column="2"> + <property name="name"> + <cstring>Layout12</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel1_4</cstring> + </property> + <property name="text"> + <string>Available Fields</string> + </property> + </widget> + <widget class="TQListBox"> + <property name="name"> + <cstring>listBoxSortField</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>This is the list of all available fields in the selected table</string> + </property> + </widget> + </vbox> + </widget> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>layoutPage</cstring> + </property> + <attribute name="title"> + <string>Layout</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="0" column="0" rowspan="6" colspan="1"> + <property name="name"> + <cstring>TextLabel4_2_2_2_3_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_table_3.png</pixmap> + </property> + </widget> + <spacer row="5" column="5"> + <property name="name" stdset="0"> + <cstring>Spacer1_9</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQButtonGroup" row="1" column="1" rowspan="1" colspan="5"> + <property name="name"> + <cstring>ButtonGroup1</cstring> + </property> + <property name="title"> + <string>&Labels</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQRadioButton" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>radioLabelsLeft</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Labels to &left</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="whatsThis" stdset="0"> + <string>Create labels to the left of data entry fields.</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="1"> + <property name="name"> + <cstring>TextLabel3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Create labels above data entry fields.</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1"> + <property name="name"> + <cstring>TextLabel2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Create labels to the left of data entry fields.</string> + </property> + </widget> + <spacer row="1" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Maximum</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="3" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Maximum</enum> + </property> + <property name="sizeHint"> + <size> + <width>16</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQRadioButton" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>radioLabelsTop</cstring> + </property> + <property name="text"> + <string>Labels on &top</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Create labels above data entry fields.</string> + </property> + </widget> + </grid> + </widget> + <widget class="TQCheckBox" row="4" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>checkCreateLayouts</cstring> + </property> + <property name="text"> + <string>&Create layout for all</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Create a BoxLayout around the whole widget</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If you select this a BoxLayout will be created for the whole widget</string> + </property> + </widget> + <widget class="TQCheckBox" row="3" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>checkCreateButtonLayout</cstring> + </property> + <property name="text"> + <string>Create layout for &buttons</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Create a BoxLayout around the buttons</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If you select this the designer will arrange all buttons inside an BoxLayout</string> + </property> + </widget> + <widget class="TQCheckBox" row="2" column="1" rowspan="1" colspan="4"> + <property name="name"> + <cstring>checkCreateFieldLayout</cstring> + </property> + <property name="text"> + <string>Create layout for &fields</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Create a BoxLayout around the fields</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If you select this the designer will arrange all fields inside an BoxLayout</string> + </property> + </widget> + <widget class="TQSpinBox" row="0" column="2"> + <property name="name"> + <cstring>spinNumberOfColumns</cstring> + </property> + <property name="maxValue"> + <number>20</number> + </property> + <property name="value"> + <number>2</number> + </property> + <property name="toolTip" stdset="0"> + <string>Enter the number of desired columns</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the number of desired columns</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="1"> + <property name="name"> + <cstring>TextLabel1_6</cstring> + </property> + <property name="text"> + <string>Number of Columns:</string> + </property> + </widget> + <spacer row="0" column="3"> + <property name="name" stdset="0"> + <cstring>Spacer3_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>finishPage</cstring> + </property> + <attribute name="title"> + <string>Finish</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel" row="0" column="0" rowspan="5" colspan="1"> + <property name="name"> + <cstring>TextLabel4_2_2_2_3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>qtwizards_table_1.png</pixmap> + </property> + </widget> + <widget class="TQLabel" row="3" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>TextLabel1_5</cstring> + </property> + <property name="text"> + <string>Press Finish to create the widget.</string> + </property> + </widget> + <spacer row="4" column="3"> + <property name="name" stdset="0"> + <cstring>Spacer2_4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="2" column="2" rowspan="1" colspan="2"> + <property name="name" stdset="0"> + <cstring>Spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="0" column="2"> + <property name="name" stdset="0"> + <cstring>Spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQCheckBox" row="1" column="1"> + <property name="name"> + <cstring>checkBoxAutoEdit</cstring> + </property> + <property name="text"> + <string>&AutoEditing</string> + </property> + <property name="toolTip" stdset="0"> + <string>Discard changes when user klicks into another row</string> + </property> + <property name="whatsThis" stdset="0"> + <string>This property holds whether the table automatically applies edits. When the user begins an insert or update in the table there are two possible outcomes when they navigate to another record +1.the insert or update is is performed -- this occurs if AutoEditing is on +2.the insert or update is abandoned -- this occurs if AutoEditing is off</string> + </property> + </widget> + </grid> + </widget> +</widget> +<connections> + <connection> + <sender>PushButton5</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>setupDatabaseConnections()</slot> + </connection> + <connection> + <sender>checkBoxNavig</sender> + <signal>toggled(bool)</signal> + <receiver>GroupBox2</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxEdit</sender> + <signal>toggled(bool)</signal> + <receiver>GroupBox3</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>buttonReSortField</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>reSortSortField()</slot> + </connection> + <connection> + <sender>buttonRemoveSortField</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>removeSortField()</slot> + </connection> + <connection> + <sender>buttonAddSortField</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>addSortField()</slot> + </connection> + <connection> + <sender>buttonUpSortField</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>sortFieldUp()</slot> + </connection> + <connection> + <sender>buttonDownSortField</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>sortFieldDown()</slot> + </connection> + <connection> + <sender>listBoxSortField</sender> + <signal>doubleClicked(TQListBoxItem*)</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>addSortField()</slot> + </connection> + <connection> + <sender>listBoxSortedField</sender> + <signal>doubleClicked(TQListBoxItem*)</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>removeSortField()</slot> + </connection> + <connection> + <sender>listBoxSortedField</sender> + <signal>rightButtonClicked(TQListBoxItem*,const TQPoint&)</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>reSortSortField()</slot> + </connection> + <connection> + <sender>checkBoxReadOnly</sender> + <signal>toggled(bool)</signal> + <receiver>GroupBox4</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>listBoxConnection</sender> + <signal>highlighted(const TQString&)</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>connectionSelected(const TQString&)</slot> + </connection> + <connection> + <sender>listBoxTable</sender> + <signal>highlighted(const TQString&)</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>tableSelected(const TQString&)</slot> + </connection> + <connection> + <sender>buttonAddField_2</sender> + <signal>released()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>addField()</slot> + </connection> + <connection> + <sender>buttonRemoveField_2</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>removeField()</slot> + </connection> + <connection> + <sender>buttonFieldUp_2</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>fieldUp()</slot> + </connection> + <connection> + <sender>buttonFieldDown_2</sender> + <signal>clicked()</signal> + <receiver>SqlFormWizardBase</receiver> + <slot>fieldDown()</slot> + </connection> +</connections> +<tabstops> + <tabstop>PushButton5</tabstop> + <tabstop>listBoxConnection</tabstop> + <tabstop>listBoxTable</tabstop> + <tabstop>checkBoxNavig</tabstop> + <tabstop>checkBoxPrev</tabstop> + <tabstop>checkBoxNext</tabstop> + <tabstop>checkBoxFirst</tabstop> + <tabstop>checkBoxLast</tabstop> + <tabstop>checkBoxEdit</tabstop> + <tabstop>checkBoxInsert</tabstop> + <tabstop>checkBoxUpdate</tabstop> + <tabstop>checkBoxDelete</tabstop> + <tabstop>checkBoxReadOnly</tabstop> + <tabstop>checkBoxConfirmInserts</tabstop> + <tabstop>checkBoxConfirmUpdates</tabstop> + <tabstop>checkBoxConfirmDeletes</tabstop> + <tabstop>checkBoxConfirmCancels</tabstop> + <tabstop>checkBoxSorting</tabstop> + <tabstop>editFilter</tabstop> + <tabstop>listBoxSortField</tabstop> + <tabstop>buttonAddSortField</tabstop> + <tabstop>buttonRemoveSortField</tabstop> + <tabstop>buttonUpSortField</tabstop> + <tabstop>buttonDownSortField</tabstop> + <tabstop>buttonReSortField</tabstop> + <tabstop>listBoxSortedField</tabstop> + <tabstop>spinNumberOfColumns</tabstop> + <tabstop>radioLabelsLeft</tabstop> + <tabstop>radioLabelsTop</tabstop> + <tabstop>checkCreateFieldLayout</tabstop> + <tabstop>checkCreateButtonLayout</tabstop> + <tabstop>checkCreateLayouts</tabstop> +</tabstops> +<slots> + <slot access="protected">init()</slot> + <slot access="protected">destroy()</slot> + <slot access="protected">addField()</slot> + <slot access="protected">addSortField()</slot> + <slot access="protected">fieldDown()</slot> + <slot access="protected">fieldUp()</slot> + <slot access="protected">reSortSortField()</slot> + <slot access="protected">removeField()</slot> + <slot access="protected">removeSortField()</slot> + <slot access="protected">setupDatabaseConnections()</slot> + <slot access="protected">sortFieldDown()</slot> + <slot access="protected">sortFieldUp()</slot> + <slot access="protected">connectionSelected( const TQString & )</slot> + <slot access="protected">tableSelected( const TQString & )</slot> +</slots> +<pixmapinproject/> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/tools/designer/plugins/wizards/sqlformwizardimpl.cpp b/tools/designer/plugins/wizards/sqlformwizardimpl.cpp new file mode 100644 index 000000000..63678756e --- /dev/null +++ b/tools/designer/plugins/wizards/sqlformwizardimpl.cpp @@ -0,0 +1,624 @@ + /********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "sqlformwizardimpl.h" + +#include <qlistbox.h> +#include <qwidget.h> +#include <qcheckbox.h> +#include <qlineedit.h> + +#include <qlabel.h> +#include <qgroupbox.h> +#include <qlayout.h> +#include <qregexp.h> +#include <qpushbutton.h> +#include <qmultilineedit.h> +#include <qlistview.h> +#include <qfeatures.h> +#include <qradiobutton.h> +#include <qspinbox.h> +#include <limits.h> + +#ifndef QT_NO_SQL +#include <qdatatable.h> +#include <qdatabrowser.h> +#include <qdataview.h> +#include <qsqleditorfactory.h> +#include <qsqlindex.h> +#include <qsqlcursor.h> +#endif + +SqlFormWizard::SqlFormWizard( TQUnknownInterface *aIface, TQWidget *w, + TQWidget* parent, DesignerFormWindow *fw, const char* name, bool modal, WFlags fl ) + : SqlFormWizardBase( parent, name, modal, fl ), widget( w ), appIface( aIface ), + mode( None ) +{ + appIface->addRef(); + formWindow = fw; + setFinishEnabled( finishPage, TRUE ); + + /* set mode of operation */ + if ( ::qt_cast<TQDataTable*>(widget) ) { + setCaption( "Data Table Wizard" ); + mode = Table; + setAppropriate( navigPage, FALSE ); + setAppropriate( layoutPage, FALSE ); + checkBoxAutoEdit->setChecked( FALSE ); + } else if ( ::qt_cast<TQDataBrowser*>(widget) ) { + setCaption( "Data Browser Wizard" ); + setAppropriate( tablePropertiesPage, FALSE ); + mode = Browser; + checkBoxAutoEdit->setChecked( TRUE ); + } else if ( ::qt_cast<TQDataView*>(widget) ) { + setCaption( "Data View Wizard" ); + setAppropriate( tablePropertiesPage, FALSE ); + setAppropriate( navigPage, FALSE ); + setAppropriate( sqlPage, FALSE); + checkCreateFieldLayout->hide(); + checkCreateButtonLayout->hide(); + checkBoxAutoEdit->hide(); + mode = View; + } + + connect( nextButton(), SIGNAL(clicked()), SLOT(nextPageClicked()) ); + setupPage1(); +} + + +SqlFormWizard::~SqlFormWizard() +{ + appIface->release(); +} + +void SqlFormWizard::nextPageClicked() +{ + if ( currentPage() == populatePage ) { + autoPopulate( TRUE ); + } +} + +void SqlFormWizard::connectionSelected( const TQString &c ) +{ + if ( !appIface ) + return; + + DesignerProject *proIface = (DesignerProject*)( (DesignerInterface*)appIface )->currentProject(); + if ( !proIface ) + return; + + listBoxTable->clear(); + TQPtrList<DesignerDatabase> databases = proIface->databaseConnections(); + for ( DesignerDatabase *d = databases.first(); d; d = databases.next() ) { + if ( d->name() == c || ( d->name() == "(default)" || d->name().isEmpty() ) && c == "(default)") + listBoxTable->insertStringList( d->tables() ); + } + setNextEnabled( databasePage, ( listBoxTable->currentItem() >= 0 ) ); +} + +void SqlFormWizard::tableSelected( const TQString & ) +{ + if ( listBoxTable->currentItem() >= 0 ) { + setNextEnabled( databasePage, TRUE ); + } else { + setNextEnabled( databasePage, FALSE ); + } + +} + +void SqlFormWizard::autoPopulate( bool populate ) +{ + DesignerProject *proIface = (DesignerProject*)( (DesignerInterface*)appIface )->currentProject(); + if ( !proIface ) + return; + TQPtrList<DesignerDatabase> databases = proIface->databaseConnections(); + listBoxField->clear(); + listBoxSortField->clear(); + listBoxSelectedField->clear(); + if ( populate ) { + for ( DesignerDatabase *d = databases.first(); d; d = databases.next() ) { + if ( d->name() == listBoxConnection->currentText() || + ( ( d->name() == "(default)" || d->name().isEmpty() ) && + listBoxConnection->currentText() == "(default)" ) ) { + TQStringList lst = *d->fields().find( listBoxTable->currentText() ); + // remove primary index fields, if any + listBoxSortField->insertStringList( lst ); + d->open( FALSE ); +#ifndef QT_NO_SQL + TQSqlCursor tab( listBoxTable->currentText(), TRUE, d->connection() ); + TQSqlIndex pIdx = tab.primaryIndex(); + for ( uint i = 0; i < pIdx.count(); i++ ) { + listBoxField->insertItem( pIdx.field( i )->name() ); + lst.remove( pIdx.field( i )->name() ); + } +#endif + d->close(); + listBoxSelectedField->insertStringList( lst ); + } + } + } +} + +void SqlFormWizard::fieldDown() +{ + if ( listBoxSelectedField->currentItem() == -1 || + listBoxSelectedField->currentItem() == (int)listBoxSelectedField->count() - 1 || + listBoxSelectedField->count() < 2 ) + return; + int index = listBoxSelectedField->currentItem() + 1; + TQListBoxItem *i = listBoxSelectedField->item( listBoxSelectedField->currentItem() ); + listBoxSelectedField->takeItem( i ); + listBoxSelectedField->insertItem( i, index ); + listBoxSelectedField->setCurrentItem( i ); +} + +void SqlFormWizard::fieldUp() +{ + if ( listBoxSelectedField->currentItem() <= 0 || + listBoxSelectedField->count() < 2 ) + return; + int index = listBoxSelectedField->currentItem() - 1; + TQListBoxItem *i = listBoxSelectedField->item( listBoxSelectedField->currentItem() ); + listBoxSelectedField->takeItem( i ); + listBoxSelectedField->insertItem( i, index ); + listBoxSelectedField->setCurrentItem( i ); +} + +void SqlFormWizard::removeField() +{ + int i = listBoxSelectedField->currentItem(); + if ( i != -1 ) { + listBoxField->insertItem( listBoxSelectedField->currentText() ); + listBoxSelectedField->removeItem( i ); + } +} + +void SqlFormWizard::addField() +{ + int i = listBoxField->currentItem(); + if ( i == -1 ) + return; + TQString f = listBoxField->currentText(); + if ( !f.isEmpty() ) + listBoxSelectedField->insertItem( f ); + listBoxField->removeItem( i ); +} + +void SqlFormWizard::addSortField() +{ + int i = listBoxSortField->currentItem(); + if ( i == -1 ) + return; + TQString f = listBoxSortField->currentText(); + if ( !f.isEmpty() ) + listBoxSortedField->insertItem( f + " ASC" ); +} + +void SqlFormWizard::reSortSortField() +{ + int i = listBoxSortedField->currentItem(); + if ( i != -1 ) { + TQString text = listBoxSortedField->currentText(); + if ( text.mid( text.length() - 3 ) == "ASC" ) + text = text.mid( 0, text.length() - 3 ) + "DESC"; + else if ( text.mid( text.length() - 4 ) == "DESC" ) + text = text.mid( 0, text.length() - 4 ) + "ASC"; + listBoxSortedField->removeItem( i ); + listBoxSortedField->insertItem( text, i ); + listBoxSortedField->setCurrentItem( i ); + } +} + +void SqlFormWizard::removeSortField() +{ + int i = listBoxSortedField->currentItem(); + if ( i != -1 ) { + listBoxSortedField->removeItem( i ); + } +} + +void SqlFormWizard::sortFieldUp() +{ + if ( listBoxSortedField->currentItem() <= 0 || + listBoxSortedField->count() < 2 ) + return; + int index = listBoxSortedField->currentItem() - 1; + TQListBoxItem *i = listBoxSortedField->item( listBoxSortedField->currentItem() ); + listBoxSortedField->takeItem( i ); + listBoxSortedField->insertItem( i, index ); + listBoxSortedField->setCurrentItem( i ); +} + +void SqlFormWizard::sortFieldDown() +{ + if ( listBoxSortedField->currentItem() == -1 || + listBoxSortedField->currentItem() == (int)listBoxSortedField->count() - 1 || + listBoxSortedField->count() < 2 ) + return; + int index = listBoxSortedField->currentItem() + 1; + TQListBoxItem *i = listBoxSortedField->item( listBoxSortedField->currentItem() ); + listBoxSortedField->takeItem( i ); + listBoxSortedField->insertItem( i, index ); + listBoxSortedField->setCurrentItem( i ); +} + +void SqlFormWizard::setupDatabaseConnections() +{ + if ( !appIface ) + return; + + DesignerProject *proIface = (DesignerProject*)( (DesignerInterface*)appIface )->currentProject(); + if ( !proIface ) + return; + proIface->setupDatabases(); + raise(); + setupPage1(); +} + +void SqlFormWizard::setupPage1() +{ + if ( !appIface ) + return; + + DesignerProject *proIface = (DesignerProject*)( (DesignerInterface*)appIface )->currentProject(); + if ( !proIface ) + return; + + listBoxTable->clear(); + listBoxConnection->clear(); + TQPtrList<DesignerDatabase> databases = proIface->databaseConnections(); + TQStringList lst; + for ( DesignerDatabase *d = databases.first(); d; d = databases.next() ) + lst << d->name(); + listBoxConnection->insertStringList( lst ); + if ( lst.count() ) + listBoxConnection->setCurrentItem( 0 ); + + setNextEnabled( databasePage, FALSE ); +} + +static TQPushButton *create_widget( TQWidget *parent, const char *name, + const TQString &txt, const TQRect &r, DesignerFormWindow *fw ) +{ + TQPushButton *pb = (TQPushButton*)fw->create( "TQPushButton", parent, name ); + pb->setText( txt ); + pb->setGeometry( r ); + fw->setPropertyChanged( pb, "text", TRUE ); + fw->setPropertyChanged( pb, "geometry", TRUE ); + return pb; +} + +void SqlFormWizard::accept() +{ + if ( !appIface || mode == None ) + return; + +#ifndef QT_NO_SQL + DesignerProject *proIface = (DesignerProject*)( (DesignerInterface*)appIface )->currentProject(); + if ( !widget || !proIface ) { + SqlFormWizardBase::accept(); + return; + } + + TQString conn = listBoxConnection->currentText(); + TQString table = listBoxTable->currentText(); + TQStringList lst; + lst << conn << table; + + if ( !conn.isEmpty() && !table.isEmpty() ) { + formWindow->setProperty( widget, "database", lst ); + formWindow->setPropertyChanged( widget, "database", TRUE ); + } + + if ( !editFilter->text().isEmpty() ) { + widget->setProperty( "filter", editFilter->text() ); + formWindow->setPropertyChanged( widget, "filter", TRUE ); + } + + if ( listBoxSortedField->count() ) { + TQStringList lst; + for ( uint i = 0; i < listBoxSortedField->count(); ++i ) + lst << listBoxSortedField->text( i ); + widget->setProperty( "sort", lst ); + formWindow->setPropertyChanged( widget, "sort", TRUE ); + } + + TQPtrList<DesignerDatabase> databases = proIface->databaseConnections(); + DesignerDatabase *database = 0; + for ( DesignerDatabase *d = databases.first(); d; d = databases.next() ) { + if ( d->name() == listBoxConnection->currentText() || ( d->name() == "(default)" || d->name().isEmpty() ) && listBoxConnection->currentText() == "(default)" ) { + database = d; + d->open( FALSE ); + break; + } + } + + if (!database) { + return; + } + TQSqlCursor tab( listBoxTable->currentText(), TRUE, database->connection() ); + int columns = 2; + + TQSqlEditorFactory * f = TQSqlEditorFactory::defaultFactory(); + + TQWidget * editorDummy; + TQWidget * editor; + TQLabel * label; + + int visibleFields = listBoxSelectedField->count(); + int numPerColumn = visibleFields / columns; + if( (visibleFields % columns) > 0) + numPerColumn++; + + int row = 0; + const int SPACING = 25; + const int COL_SPACING = SPACING*9; + + uint j; + switch ( mode ) { + case None: + break; + case View: + case Browser: { + + if ( mode == Browser && !checkBoxAutoEdit->isChecked() ) { + ((TQDataBrowser*)widget)->setAutoEdit( FALSE ); + formWindow->setPropertyChanged( widget, "autoEdit", TRUE ); + } + + formWindow->clearSelection(); + bool createFieldLayout = checkCreateFieldLayout->isChecked(); + bool createButtonLayout = checkCreateButtonLayout->isChecked(); + bool createLayouts = checkCreateLayouts->isChecked(); + bool labelAbove = radioLabelsTop->isOn(); + uint numCols = spinNumberOfColumns->text().toInt(); + uint currentCol = 0; + uint fieldsPerCol = listBoxSelectedField->count(); + uint fieldsInCol = 0; + if ( listBoxSelectedField->count() ) + fieldsPerCol = listBoxSelectedField->count() / numCols; + /* labels and data field editors */ + for( j = 0; j < listBoxSelectedField->count(); j++ ){ + + TQSqlField* field = tab.field( listBoxSelectedField->text( j ) ); + if ( !field ) + continue; + + /* label */ + TQString labelName = field->name(); + labelName = labelName.mid(0,1).upper() + labelName.mid(1); + label = (TQLabel*)formWindow->create( "TQLabel", widget, + TQString( "label" + labelName ) ); + label->setText( labelName ); + label->setGeometry( SPACING + currentCol*COL_SPACING, row+SPACING, + SPACING*3, SPACING ); + + formWindow->setPropertyChanged( label, "geometry", TRUE ); + formWindow->setPropertyChanged( label, "text", TRUE ); + + /* editor */ + editorDummy = f->createEditor( widget, field ); + editor = formWindow->create( editorDummy->className(), widget, + TQString( TQString( editorDummy->className() ) + + labelName) ); + delete editorDummy; + if ( labelAbove ) { + row += SPACING; + editor->setGeometry(SPACING + currentCol*COL_SPACING, row+SPACING, + SPACING*3, SPACING ); + } else { + editor->setGeometry(SPACING * 5 + currentCol*COL_SPACING, row+SPACING, + SPACING*3, SPACING ); + } + formWindow->setPropertyChanged( editor, "geometry", TRUE ); + if ( TQString(editor->className()) == "TQLineEdit" && + (field->type() == TQVariant::Double || + field->type() == TQVariant::Int || + field->type() == TQVariant::UInt ) ) { + /* default right-align numerics */ + //## + ((TQLineEdit*)editor)->setAlignment( TQt::AlignRight ); + formWindow->setPropertyChanged( editor, "alignment", TRUE ); + } + if ( ::qt_cast<TQSpinBox*>(editor) ) { + ( (TQSpinBox*)editor )->setMaxValue( INT_MAX ); + formWindow->setPropertyChanged( editor, "maxValue", TRUE ); + } + TQStringList lst; + lst << conn << table << field->name(); + formWindow->setProperty( editor, "database", lst ); + formWindow->setPropertyChanged( editor, "database", TRUE ); + + /* geometry */ + if ( createFieldLayout ) { + formWindow->selectWidget( label ); + formWindow->selectWidget( editor ); + } + + row += SPACING + 5; + fieldsInCol++; + if ( ( fieldsInCol >= fieldsPerCol ) && ( currentCol < numCols-1 ) ) { + currentCol++; + fieldsInCol = 0; + row = 0; + } + } + + if ( listBoxSelectedField->count() ) { + if ( createFieldLayout ) + formWindow->layoutG(); + row += SPACING; + } + + if ( mode == Browser ) { + if ( checkBoxNavig->isChecked() ) { + formWindow->clearSelection(); + currentCol = 0; + if ( checkBoxFirst->isChecked() ) { + TQPushButton *pb = create_widget( widget, "PushButtonFirst", + "|< &First", + TQRect( 3 * SPACING * currentCol, row+SPACING, SPACING * 3, SPACING ), + formWindow ); + formWindow->addConnection( pb, "clicked()", widget, "first()" ); + formWindow->addConnection( widget, "firstRecordAvailable( bool )", + pb, "setEnabled( bool )" ); + currentCol++; + formWindow->selectWidget( pb ); + } + if ( checkBoxPrev->isChecked() ) { + TQPushButton *pb = create_widget( widget, "PushButtonPrev", + "<< &Prev", + TQRect( 3 * SPACING * currentCol, row+SPACING, SPACING * 3, SPACING ), + formWindow ); + formWindow->addConnection( pb, "clicked()", widget, "prev()" ); + formWindow->addConnection( widget, "prevRecordAvailable( bool )", + pb, "setEnabled( bool )" ); + currentCol++; + formWindow->selectWidget( pb ); + } + if ( checkBoxNext->isChecked() ) { + TQPushButton *pb = create_widget( widget, "PushButtonNext", + "&Next >>", + TQRect( 3 * SPACING * currentCol, row+SPACING, SPACING * 3, SPACING ), + formWindow ); + formWindow->addConnection( pb, "clicked()", widget, "next()" ); + formWindow->addConnection( widget, "nextRecordAvailable( bool )", pb, + "setEnabled( bool )" ); + currentCol++; + formWindow->selectWidget( pb ); + } + if ( checkBoxLast->isChecked() ) { + TQPushButton *pb = create_widget( widget, "PushButtonLast", "&Last >|", + TQRect( 3 * SPACING * currentCol, row+SPACING, SPACING*3, SPACING ), formWindow ); + formWindow->addConnection( pb, "clicked()", widget, "last()" ); + formWindow->addConnection( widget, "lastRecordAvailable( bool )", pb, + "setEnabled( bool )" ); + currentCol++; + formWindow->selectWidget( pb ); + } + if ( createButtonLayout ) + formWindow->layoutH(); + } + if ( checkBoxEdit->isChecked() ) { + formWindow->clearSelection(); + row += SPACING; + currentCol = 0; + if ( checkBoxInsert->isChecked() ) { + TQPushButton *pb = create_widget( widget, "PushButtonInsert", "&Insert", + TQRect( 3 * SPACING * currentCol, row+SPACING, SPACING * 3, SPACING ), formWindow ); + formWindow->addConnection( pb, "clicked()", widget, "insert()" ); + currentCol++; + formWindow->selectWidget( pb ); + } + if ( checkBoxUpdate->isChecked() ) { + TQPushButton *pb = create_widget( widget, "PushButtonUpdate", "&Update", + TQRect( 3 * SPACING * currentCol, row+SPACING, SPACING * 3, SPACING ), formWindow ); + formWindow->addConnection( pb, "clicked()", widget, "update()" ); + currentCol++; + formWindow->selectWidget( pb ); + } + if ( checkBoxDelete->isChecked() ) { + TQPushButton *pb = create_widget( widget, "PushButtonDelete", "&Delete", + TQRect( 3 * SPACING * currentCol, row+SPACING, SPACING * 3, SPACING ), formWindow ); + formWindow->addConnection( pb, "clicked()", widget, "del()" ); + currentCol++; + formWindow->selectWidget( pb ); + } + if ( createButtonLayout ) + formWindow->layoutH(); + } + } + if ( createLayouts ) + formWindow->layoutGContainer( widget ); + formWindow->clearSelection(); + break; + } + case Table: + { + TQDataTable* sqlTable = ((TQDataTable*)widget); + if ( checkBoxAutoEdit->isChecked() ) { + sqlTable->setAutoEdit( TRUE ); + formWindow->setPropertyChanged( sqlTable, "autoEdit", TRUE ); + } + + if ( checkBoxReadOnly->isChecked() ) { + sqlTable->setReadOnly( TRUE ); + formWindow->setPropertyChanged( sqlTable, "readOnly", TRUE ); + } else { + if ( checkBoxConfirmInserts->isChecked() ) { + sqlTable->setConfirmInsert( TRUE ); + formWindow->setPropertyChanged( sqlTable, "confirmInsert", TRUE ); + } + if ( checkBoxConfirmUpdates->isChecked() ) { + sqlTable->setConfirmUpdate( TRUE ); + formWindow->setPropertyChanged( sqlTable, "confirmUpdate", TRUE ); + } + if ( checkBoxConfirmDeletes->isChecked() ) { + sqlTable->setConfirmDelete( TRUE ); + formWindow->setPropertyChanged( sqlTable, "confirmDelete", TRUE ); + } + if ( checkBoxConfirmCancels->isChecked() ) { + sqlTable->setConfirmCancels( TRUE ); + formWindow->setPropertyChanged( sqlTable, "confirmCancels", TRUE ); + } + } + if ( checkBoxSorting->isChecked() ) { + sqlTable->setSorting( TRUE ); + formWindow->setPropertyChanged( sqlTable, "sorting", TRUE ); + } + + TQMap<TQString, TQString> columnFields; + sqlTable->setNumCols( listBoxSelectedField->count() ); // no need to change property through mdbIface here, since TQDataTable doesn't offer that through Designer + for( j = 0; j < listBoxSelectedField->count(); j++ ){ + + TQSqlField* field = tab.field( listBoxSelectedField->text( j ) ); + if ( !field ) + continue; + + TQString labelName = field->name(); + labelName = labelName.mid(0,1).upper() + labelName.mid(1); + + ((TQTable*)widget)->horizontalHeader()->setLabel( j, labelName ); + + columnFields.insert( labelName, field->name() ); + } + formWindow->setColumnFields( widget, columnFields ); + break; + } + } + + database->close(); +#endif + + SqlFormWizardBase::accept(); +} diff --git a/tools/designer/plugins/wizards/sqlformwizardimpl.h b/tools/designer/plugins/wizards/sqlformwizardimpl.h new file mode 100644 index 000000000..a03ed49f2 --- /dev/null +++ b/tools/designer/plugins/wizards/sqlformwizardimpl.h @@ -0,0 +1,87 @@ + /********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef SQLFORMWIZARDIMPL_H +#define SQLFORMWIZARDIMPL_H + +#include "sqlformwizard.h" +#include <templatewizardiface.h> +#include <designerinterface.h> +#include <qvaluelist.h> + +class SqlFormWizard : public SqlFormWizardBase +{ + Q_OBJECT + +public: + SqlFormWizard( TQUnknownInterface *aIface, TQWidget *w, TQWidget* parent = 0, DesignerFormWindow *fw = 0, + const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SqlFormWizard(); + + void accept() const; + +protected slots: + void connectionSelected( const TQString & ); + void tableSelected( const TQString & ); + void autoPopulate( bool populate ); + void fieldDown(); + void fieldUp(); + void removeField(); + void addField(); + void setupDatabaseConnections(); + void accept(); + void addSortField(); + void reSortSortField(); + void removeSortField(); + void sortFieldUp(); + void sortFieldDown(); + void nextPageClicked(); + +private: + void setupPage1(); + +private: + TQWidget *widget; + TQUnknownInterface *appIface; + DesignerFormWindow *formWindow; + enum Mode { + None, + View, + Browser, + Table + }; + Mode mode; + +}; + +#endif // SQLFORMWIZARDIMPL_H diff --git a/tools/designer/plugins/wizards/wizards.pro b/tools/designer/plugins/wizards/wizards.pro new file mode 100644 index 000000000..1e506934a --- /dev/null +++ b/tools/designer/plugins/wizards/wizards.pro @@ -0,0 +1,21 @@ +TEMPLATE = lib +CONFIG += qt warn_on release plugin + +SOURCES += main.cpp +FORMS = sqlformwizard.ui mainwindowwizard.ui + +sql { + HEADERS += sqlformwizardimpl.h + SOURCES += sqlformwizardimpl.cpp + } +DESTDIR = ../../../../plugins/designer + +PROJECTNAME = Wizards +IMAGES = images/qtwizards_menu_1.png images/qtwizards_menu_2.png images/qtwizards_menu_3.png images/qtwizards_table_1.png images/qtwizards_table_2.png images/qtwizards_table_3.png images/qtwizards_table_4.png images/re-sort.png images/small/editcopy.png images/small/editcut.png images/small/editpaste.png images/small/filenew.png images/small/fileopen.png images/small/filesave.png images/small/print.png images/small/redo.png images/small/searchfind.png images/small/undo.png +INCLUDEPATH += ../../interfaces +DBFILE = wizards.db +LANGUAGE = C++ + + +target.path += $$plugins.path/designer +INSTALLS += target |