summaryrefslogtreecommitdiffstats
path: root/tools/designer/plugins
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:24:15 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:24:15 -0500
commitbd0f3345a938b35ce6a12f6150373b0955b8dd12 (patch)
tree7a520322212d48ebcb9fbe1087e7fca28b76185c /tools/designer/plugins
downloadqt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.tar.gz
qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.zip
Add Qt3 development HEAD version
Diffstat (limited to 'tools/designer/plugins')
-rw-r--r--tools/designer/plugins/cppeditor/common.cpp111
-rw-r--r--tools/designer/plugins/cppeditor/cppbrowser.cpp78
-rw-r--r--tools/designer/plugins/cppeditor/cppbrowser.h50
-rw-r--r--tools/designer/plugins/cppeditor/cppcompletion.cpp220
-rw-r--r--tools/designer/plugins/cppeditor/cppcompletion.h60
-rw-r--r--tools/designer/plugins/cppeditor/cppeditor.cpp168
-rw-r--r--tools/designer/plugins/cppeditor/cppeditor.h78
-rw-r--r--tools/designer/plugins/cppeditor/cppeditor.pro21
-rw-r--r--tools/designer/plugins/cppeditor/editorinterfaceimpl.cpp338
-rw-r--r--tools/designer/plugins/cppeditor/editorinterfaceimpl.h107
-rw-r--r--tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp249
-rw-r--r--tools/designer/plugins/cppeditor/languageinterfaceimpl.h90
-rw-r--r--tools/designer/plugins/cppeditor/mainfilesettings.ui211
-rw-r--r--tools/designer/plugins/cppeditor/mainfilesettings.ui.h36
-rw-r--r--tools/designer/plugins/cppeditor/preferenceinterfaceimpl.cpp102
-rw-r--r--tools/designer/plugins/cppeditor/preferenceinterfaceimpl.h64
-rw-r--r--tools/designer/plugins/cppeditor/projectsettings.ui347
-rw-r--r--tools/designer/plugins/cppeditor/projectsettings.ui.h106
-rw-r--r--tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.cpp106
-rw-r--r--tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h62
-rw-r--r--tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.cpp117
-rw-r--r--tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h54
-rw-r--r--tools/designer/plugins/cppeditor/syntaxhighliter_cpp.cpp550
-rw-r--r--tools/designer/plugins/cppeditor/syntaxhighliter_cpp.h73
-rw-r--r--tools/designer/plugins/cppeditor/yyreg.cpp800
-rw-r--r--tools/designer/plugins/cppeditor/yyreg.h88
-rw-r--r--tools/designer/plugins/dlg/dlg.pro13
-rw-r--r--tools/designer/plugins/dlg/dlg2ui.cpp1632
-rw-r--r--tools/designer/plugins/dlg/dlg2ui.h144
-rw-r--r--tools/designer/plugins/dlg/main.cpp108
-rw-r--r--tools/designer/plugins/glade/glade.pro13
-rw-r--r--tools/designer/plugins/glade/glade2ui.cpp2203
-rw-r--r--tools/designer/plugins/glade/glade2ui.h169
-rw-r--r--tools/designer/plugins/glade/main.cpp109
-rw-r--r--tools/designer/plugins/kdevdlg/kdevdlg.pro11
-rw-r--r--tools/designer/plugins/kdevdlg/kdevdlg2ui.cpp524
-rw-r--r--tools/designer/plugins/kdevdlg/kdevdlg2ui.h90
-rw-r--r--tools/designer/plugins/kdevdlg/main.cpp120
-rw-r--r--tools/designer/plugins/plugins.pro9
-rw-r--r--tools/designer/plugins/rc/main.cpp117
-rw-r--r--tools/designer/plugins/rc/rc.pro11
-rw-r--r--tools/designer/plugins/rc/rc2ui.cpp888
-rw-r--r--tools/designer/plugins/rc/rc2ui.h103
-rw-r--r--tools/designer/plugins/wizards/images/qtwizards_menu_1.pngbin0 -> 10172 bytes
-rw-r--r--tools/designer/plugins/wizards/images/qtwizards_menu_2.pngbin0 -> 12582 bytes
-rw-r--r--tools/designer/plugins/wizards/images/qtwizards_menu_3.pngbin0 -> 11653 bytes
-rw-r--r--tools/designer/plugins/wizards/images/qtwizards_table_1.pngbin0 -> 13382 bytes
-rw-r--r--tools/designer/plugins/wizards/images/qtwizards_table_2.pngbin0 -> 15245 bytes
-rw-r--r--tools/designer/plugins/wizards/images/qtwizards_table_3.pngbin0 -> 16105 bytes
-rw-r--r--tools/designer/plugins/wizards/images/qtwizards_table_4.pngbin0 -> 7894 bytes
-rw-r--r--tools/designer/plugins/wizards/images/re-sort.pngbin0 -> 254 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/editcopy.pngbin0 -> 172 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/editcut.pngbin0 -> 157 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/editpaste.pngbin0 -> 199 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/filenew.pngbin0 -> 119 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/fileopen.pngbin0 -> 165 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/filesave.pngbin0 -> 150 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/print.pngbin0 -> 586 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/redo.pngbin0 -> 137 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/searchfind.pngbin0 -> 534 bytes
-rw-r--r--tools/designer/plugins/wizards/images/small/undo.pngbin0 -> 137 bytes
-rw-r--r--tools/designer/plugins/wizards/main.cpp142
-rw-r--r--tools/designer/plugins/wizards/mainwindowwizard.ui757
-rw-r--r--tools/designer/plugins/wizards/mainwindowwizard.ui.h321
-rw-r--r--tools/designer/plugins/wizards/sqlformwizard.ui1776
-rw-r--r--tools/designer/plugins/wizards/sqlformwizardimpl.cpp624
-rw-r--r--tools/designer/plugins/wizards/sqlformwizardimpl.h87
-rw-r--r--tools/designer/plugins/wizards/wizards.pro21
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 0000000..07b52df
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QComponentInformationInterface
+{
+public:
+ CommonInterface();
+ virtual ~CommonInterface();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT;
+
+ QString name() const { return "C++"; }
+ QString description() const { return "C++ Integration"; }
+ QString version() const { return "0.1"; }
+ QString 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();
+}
+
+QRESULT CommonInterface::queryInterface( const QUuid &uuid, QUnknownInterface** iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)this;
+ else if ( uuid == IID_QComponentInformation )
+ *iface = (QComponentInformationInterface*)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 QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_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 0000000..3d004b5
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString &w )
+{
+ QString 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";
+ QStringList lst;
+ lst << "assistant" << "-file" << word;
+ QProcess proc( lst );
+ proc.start();
+ return;
+ }
+
+ if ( word.find( '(' ) != -1 ) {
+ QString txt = "::" + word.left( word.find( '(' ) );
+ QTextDocument *doc = curEditor->document();
+ QTextParagraph *p = doc->firstParagraph();
+ while ( p ) {
+ if ( p->string()->toString().find( txt ) != -1 ) {
+ curEditor->setCursorPosition( p->paragId(), 0 );
+ return;
+ }
+ p = p->next();
+ }
+ }
+
+ QMainWindow *mw = ::qt_cast<QMainWindow*>(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 0000000..92f07b9
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString &word );
+
+};
+
+#endif
diff --git a/tools/designer/plugins/cppeditor/cppcompletion.cpp b/tools/designer/plugins/cppeditor/cppcompletion.cpp
new file mode 100644
index 0000000..464aedb
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString &objName )
+{
+ if ( !ths )
+ return FALSE;
+ QString 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();
+ QObject *obj = 0;
+ if ( ths->name() == object || object == "this" ) {
+ obj = ths;
+ } else {
+ obj = ths->child( object );
+ }
+
+ if ( !obj )
+ return FALSE;
+
+ QValueList<CompletionEntry> lst;
+
+ if ( obj->children() ) {
+ for ( QObjectListIt cit( *obj->children() ); cit.current(); ++cit ) {
+ QString 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;
+ }
+ }
+ }
+
+ QStrList props = obj->metaObject()->propertyNames( TRUE );
+ for ( QPtrListIterator<char> pit( props ); pit.current(); ++pit ) {
+ QString f( pit.current() );
+ QChar 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;
+ }
+
+ QStrList slts = obj->metaObject()->slotNames( TRUE );
+ for ( QPtrListIterator<char> sit( slts ); sit.current(); ++sit ) {
+ QString 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;
+}
+
+QValueList<QStringList> CppEditorCompletion::functionParameters( const QString &expr, QChar &separator,
+ QString &prefix, QString &postfix )
+{
+ Q_UNUSED( prefix );
+ Q_UNUSED( postfix );
+ separator = ',';
+ if ( !ths )
+ return QValueList<QStringList>();
+ QString func;
+ QString 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();
+ QString 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();
+ }
+
+ QObject *obj = 0;
+ if ( ths->name() == objName || objName == "this" ) {
+ obj = ths;
+ } else {
+ obj = ths->child( objName );
+ }
+
+ if ( !obj )
+ return QValueList<QStringList>();
+
+ QStrList slts = obj->metaObject()->slotNames( TRUE );
+ for ( QPtrListIterator<char> sit( slts ); sit.current(); ++sit ) {
+ QString f( sit.current() );
+ f = f.left( f.find( "(" ) );
+ if ( f == func ) {
+ f = QString( sit.current() );
+ f.remove( (uint)0, f.find( "(" ) + 1 );
+ f = f.left( f.find( ")" ) );
+ QStringList lst = QStringList::split( ',', f );
+ if ( !lst.isEmpty() ) {
+ QValueList<QStringList> l;
+ l << lst;
+ return l;
+ }
+ }
+ }
+
+ const QMetaProperty *prop =
+ obj->metaObject()->
+ property( obj->metaObject()->findProperty( func[ 3 ].lower() + func.mid( 4 ), TRUE ), TRUE );
+ if ( prop ) {
+ QValueList<QStringList> l;
+ l << QStringList( prop->type() );
+ return l;
+ }
+
+ return QValueList<QStringList>();
+}
+
+void CppEditorCompletion::setContext( QObject *this_ )
+{
+ ths = this_;
+}
diff --git a/tools/designer/plugins/cppeditor/cppcompletion.h b/tools/designer/plugins/cppeditor/cppcompletion.h
new file mode 100644
index 0000000..170c850
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString &object );
+ QValueList<QStringList> functionParameters( const QString &func, QChar &, QString &prefix, QString &postfix );
+ void setContext( QObject *this_ );
+
+private:
+ QGuardedPtr<QObject> ths;
+
+};
+
+#endif
diff --git a/tools/designer/plugins/cppeditor/cppeditor.cpp b/tools/designer/plugins/cppeditor/cppeditor.cpp
new file mode 100644
index 0000000..37aa9cc
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString &fn, QWidget *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 ] != QString::null )
+ completion->addCompletionEntry( SyntaxHighlighter_CPP::keywords[ j++ ], 0, FALSE );
+ configChanged();
+}
+
+CppEditor::~CppEditor()
+{
+ delete completion;
+ if ( dIface )
+ dIface->release();
+}
+
+void CppEditor::configChanged()
+{
+ QString path = "/Trolltech/CppEditor/";
+ QMap<QString, 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 QTextFormatterBreakInWords );
+ setHScrollBarMode( AlwaysOff );
+ }
+ } else {
+ if ( hScrollBarMode() != AlwaysOn ) {
+ QTextFormatterBreakWords *f = new QTextFormatterBreakWords;
+ 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( QTextPreProcessor::Standard )->width( 'x' ) * Config::indentTabSize( path ) );
+
+ Editor::configChanged();
+}
+
+QPopupMenu *CppEditor::createPopupMenu( const QPoint &p )
+{
+ QPopupMenu *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;
+ QString s = QInputDialog::getText( tr( "Add Include File (In Declaration)" ),
+ tr( "Input this using the format <b>&lt;include.h&gt;</b> or <b>\"include.h\"</b>" ) );
+ if ( s.isEmpty() )
+ return;
+ DesignerFormWindow *form = dIface->currentForm();
+ QStringList lst = form->declarationIncludes();
+ lst << s;
+ form->setDeclarationIncludes( lst );
+}
+
+void CppEditor::addInclImpl()
+{
+ if ( !dIface )
+ return;
+ QString s = QInputDialog::getText( tr( "Add Include File (In Implementation)" ),
+ tr( "Input this using the format <b>&lt;include.h&gt;</b> or <b>\"include.h\"</b>" ) );
+ if ( s.isEmpty() )
+ return;
+ DesignerFormWindow *form = dIface->currentForm();
+ QStringList lst = form->implementationIncludes();
+ lst << s;
+ form->setImplementationIncludes( lst );
+}
+
+void CppEditor::addForward()
+{
+ if ( !dIface )
+ return;
+ QString s = QInputDialog::getText( tr( "Add Forward Declaration" ),
+ tr( "Input this using the format <b>ClassName;</b>" ) );
+ if ( s.isEmpty() )
+ return;
+ DesignerFormWindow *form = dIface->currentForm();
+ QStringList 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 0000000..05d7930
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString &fn, QWidget *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 QTextEdit::createPopupMenu;
+#endif
+ QPopupMenu *createPopupMenu( const QPoint &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 0000000..391c1d7
--- /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 0000000..d396720
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QTimer( this );
+ connect( updateTimer, SIGNAL( timeout() ),
+ this, SLOT( update() ) );
+}
+
+EditorInterfaceImpl::~EditorInterfaceImpl()
+{
+ updateTimer->stop();
+ delete (ViewManager*)viewManager;
+ if ( dIface )
+ dIface->release();
+}
+
+QRESULT EditorInterfaceImpl::queryInterface( const QUuid &uuid, QUnknownInterface** iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)this;
+ else if ( uuid == IID_Editor )
+ *iface = (EditorInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+QWidget *EditorInterfaceImpl::editor( bool readonly,
+ QWidget *parent, QUnknownInterface *iface )
+{
+ if ( !viewManager ) {
+ ( (EditorInterfaceImpl*)this )->viewManager = new ViewManager( parent, 0 );
+ ( (EditorInterfaceImpl*)this )->viewManager->showMarkerWidget( FALSE );
+ if ( iface )
+ iface->queryInterface( IID_Designer, (QUnknownInterface**) &dIface );
+ CppEditor *e = new CppEditor( QString::null, viewManager, "editor", dIface );
+ e->setEditable( !readonly );
+ e->installEventFilter( this );
+ connect( e, SIGNAL( intervalChanged() ), this, SLOT( intervalChanged() ) );
+ QApplication::sendPostedEvents( viewManager, QEvent::ChildInserted );
+ }
+ return viewManager->currentView();
+}
+
+void EditorInterfaceImpl::setText( const QString &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 ) ) );
+}
+
+QString EditorInterfaceImpl::text() const
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return QString::null;
+ QString 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 QString &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 QString &find, const QString &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() )->QTextEdit::indent();
+}
+
+void EditorInterfaceImpl::splitView()
+{
+#if 0
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ QTextDocument *doc = ( (CppEditor*)viewManager->currentView() )->document();
+ CppEditor *editor = new CppEditor( QString::null, viewManager, "editor" );
+ editor->setDocument( doc );
+#endif
+}
+
+void EditorInterfaceImpl::scrollTo( const QString &txt, const QString & )
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->sync();
+ QTextDocument *doc = ( (CppEditor*)viewManager->currentView() )->document();
+ QTextParagraph *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( QObject *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( QObject *o, QEvent *e )
+{
+ if ( e->type() == QEvent::KeyPress )
+ updateTimer->stop();
+ else if ( e->type() == QEvent::FocusOut )
+ update();
+
+ return QObject::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( QObject *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 0000000..06b3d2a
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QTimer;
+class ViewManager;
+struct DesignerInterface;
+
+class EditorInterfaceImpl : public QObject, public EditorInterface
+{
+ Q_OBJECT
+
+public:
+ EditorInterfaceImpl();
+ virtual ~EditorInterfaceImpl();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT;
+
+ QWidget *editor( bool readonly, QWidget *parent, QUnknownInterface *designerIface );
+
+ void setText( const QString &txt );
+ QString text() const;
+ bool isUndoAvailable() const;
+ bool isRedoAvailable() const;
+ void undo();
+ void redo();
+ void cut();
+ void copy();
+ void paste();
+ void selectAll();
+ bool find( const QString &expr, bool cs, bool wo, bool forward, bool startAtCursor );
+ bool replace( const QString &find, const QString &replace, bool cs, bool wo, bool forward, bool startAtCursor, bool replaceAll );
+ void gotoLine( int line );
+ void indent();
+ void scrollTo( const QString &txt, const QString &first );
+ void splitView();
+ void setContext( QObject *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( QValueList<uint> & ) const {}
+ void setBreakPoints( const QValueList<uint> & ) {}
+ void onBreakPointChange( QObject *receiver, const char *slot );
+ void clearStackFrame() {}
+ void setStackFrame( int ) {}
+
+protected:
+ bool eventFilter( QObject*, QEvent* );
+
+private slots:
+ void modificationChanged( bool m );
+ void intervalChanged();
+ void update();
+
+private:
+ QGuardedPtr<ViewManager> viewManager;
+ DesignerInterface *dIface;
+ QTimer *updateTimer;
+
+};
+
+#endif
diff --git a/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp b/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp
new file mode 100644
index 0000000..124be70
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QUnknownInterface *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;
+}
+
+QRESULT LanguageInterfaceImpl::queryInterface( const QUuid &uuid, QUnknownInterface** iface )
+{
+ if ( parent )
+ return parent->queryInterface( uuid, iface );
+
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)this;
+ else if ( uuid == IID_Language )
+ *iface = (LanguageInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+
+class NormalizeObject : public QObject
+{
+public:
+ NormalizeObject() : QObject() {}
+ static QCString normalizeSignalSlot( const char *signalSlot ) { return QObject::normalizeSignalSlot( signalSlot ); }
+};
+
+void LanguageInterfaceImpl::functions( const QString &code, QValueList<Function> *functionMap ) const
+{
+ QValueList<CppFunction> l;
+ extractCppFunctions( code, &l );
+ for ( QValueList<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 );
+ }
+}
+
+QString LanguageInterfaceImpl::createFunctionStart( const QString &className, const QString &func,
+ const QString &returnType,
+ const QString & )
+{
+ return returnType + " " + className + "::" + func;
+}
+
+QStringList LanguageInterfaceImpl::definitions() const
+{
+ QStringList lst;
+ lst << "Includes (in Implementation)" << "Includes (in Declaration)" << "Forward Declarations" << "Signals";
+ return lst;
+}
+
+QStringList LanguageInterfaceImpl::definitionEntries( const QString &definition, QUnknownInterface *designerIface ) const
+{
+ DesignerInterface *iface = 0;
+ designerIface->queryInterface( IID_Designer, (QUnknownInterface**) &iface );
+ if ( !iface )
+ return QStringList();
+ DesignerFormWindow *fw = iface->currentForm();
+ if ( !fw )
+ return QStringList();
+ QStringList 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 QString &definition, const QStringList &entries, QUnknownInterface *designerIface )
+{
+ DesignerInterface *iface = 0;
+ designerIface->queryInterface( IID_Designer, (QUnknownInterface**) &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();
+}
+
+QString LanguageInterfaceImpl::createEmptyFunction()
+{
+ return "{\n\n}\n";
+}
+
+bool LanguageInterfaceImpl::supports( Support s ) const
+{
+ if ( s == ReturnType )
+ return TRUE;
+ if ( s == ConnectionsToCustomSlots )
+ return TRUE;
+ return FALSE;
+}
+
+QStringList LanguageInterfaceImpl::fileFilterList() const
+{
+ QStringList f;
+ f << "C++ Files (*.cpp *.C *.cxx *.c++ *.c *.h *.H *.hpp *.hxx)";
+ return f;
+
+}
+QStringList LanguageInterfaceImpl::fileExtensionList() const
+{
+ QStringList f;
+ f << "cpp" << "C" << "cxx" << "c++" << "c" <<"h" << "H" << "hpp" << "hxx";
+ return f;
+}
+
+QString LanguageInterfaceImpl::projectKeyForExtension( const QString &extension ) const
+{
+ // also handle something like foo.ut.cpp
+ QString 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( QStringList &keys ) const
+{
+ keys << "HEADERS" << "SOURCES";
+}
+
+ class CheckObject : public QObject
+{
+public:
+ CheckObject() {}
+ bool checkConnectArgs( const char *signal, const char *member ) { return QObject::checkConnectArgs( signal, 0, member ); }
+
+};
+
+bool LanguageInterfaceImpl::canConnect( const QString &signal, const QString &slot )
+{
+ CheckObject o;
+ return o.checkConnectArgs( signal.latin1(), slot.latin1() );
+}
+
+void LanguageInterfaceImpl::loadFormCode( const QString &, const QString &filename,
+ QValueList<Function> &functions,
+ QStringList &,
+ QValueList<Connection> & )
+{
+ QFile f( filename );
+ if ( !f.open( IO_ReadOnly ) )
+ return;
+ QTextStream ts( &f );
+ QString code( ts.read() );
+ this->functions( code, &functions );
+}
+
+void LanguageInterfaceImpl::preferedExtensions( QMap<QString, QString> &extensionMap ) const
+{
+ extensionMap.insert( "cpp", "C++ Source File" );
+ extensionMap.insert( "h", "C++ Header File" );
+}
+
+QStrList LanguageInterfaceImpl::signalNames( QObject *obj ) const
+{
+ QStrList 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 0000000..55781e7
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QUnknownInterface *outer = 0 );
+
+ ulong addRef();
+ ulong release();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+
+ void functions( const QString &code, QValueList<Function> *funcs ) const;
+ void connections( const QString &, QValueList<Connection> * ) const {};
+ QString createFunctionStart( const QString &className, const QString &func,
+ const QString &returnType, const QString &access );
+ QStringList definitions() const;
+ QStringList definitionEntries( const QString &definition, QUnknownInterface *designerIface ) const;
+ void setDefinitionEntries( const QString &definition, const QStringList &entries, QUnknownInterface *designerIface );
+ QString createArguments( const QString & ) { return QString::null; }
+ QString createEmptyFunction();
+ bool supports( Support s ) const;
+ QStringList fileFilterList() const;
+ QStringList fileExtensionList() const;
+ void preferedExtensions( QMap<QString, QString> &extensionMap ) const;
+ void sourceProjectKeys( QStringList &keys ) const;
+ QString projectKeyForExtension( const QString &extension ) const;
+ QString cleanSignature( const QString &sig ) { return sig; } // #### implement me
+ void loadFormCode( const QString &, const QString &,
+ QValueList<Function> &,
+ QStringList &,
+ QValueList<Connection> & );
+ QString formCodeExtension() const { return ".h"; }
+ bool canConnect( const QString &signal, const QString &slot );
+ void compressProject( const QString &, const QString &, bool ) {}
+ QString uncompressProject( const QString &, const QString & ) { return QString::null; }
+ QString aboutText() const { return ""; }
+
+ void addConnection( const QString &, const QString &,
+ const QString &, const QString &,
+ QString * ) {}
+ void removeConnection( const QString &, const QString &,
+ const QString &, const QString &,
+ QString * ) {}
+ QStrList signalNames( QObject *obj ) const;
+
+private:
+ QUnknownInterface *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 0000000..2816cda
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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="QDialog">
+ <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="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Filename:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>editFileName</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Main-Form:</string>
+ </property>
+ </widget>
+ <widget class="QListBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>listForms</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" 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="QPushButton">
+ <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="QPushButton">
+ <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="QPushButton">
+ <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(QListBoxItem*)</signal>
+ <receiver>CppMainFile</receiver>
+ <slot>updateOkButton()</slot>
+ </connection>
+ <connection>
+ <sender>editFileName</sender>
+ <signal>textChanged(const QString&amp;)</signal>
+ <receiver>CppMainFile</receiver>
+ <slot>updateOkButton()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">mainfilesettings.ui.h</include>
+</includes>
+<forwards>
+ <forward>struct QUnknownInterface;</forward>
+</forwards>
+<slots>
+ <slot>init()</slot>
+ <slot>setup( QUnknownInterface * 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 0000000..ea79101
--- /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 Qt 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( QUnknownInterface *appIface )
+{
+ DesignerInterface *dIface = 0;
+ appIface->queryInterface( IID_Designer, (QUnknownInterface**)&dIface );
+ if ( !dIface )
+ return;
+ QStringList 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 0000000..b6dd10c
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QUnknownInterface *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;
+}
+
+QRESULT PreferenceInterfaceImpl::queryInterface( const QUuid &uuid, QUnknownInterface** iface )
+{
+ if ( parent )
+ return parent->queryInterface( uuid, iface );
+
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)this;
+ else if ( uuid == IID_Preference )
+ *iface = (PreferenceInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_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 0000000..e1225fc
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QWidget;
+
+class PreferenceInterfaceImpl : public PreferenceInterface
+{
+public:
+ PreferenceInterfaceImpl( QUnknownInterface *outer = 0 );
+ virtual ~PreferenceInterfaceImpl();
+
+ ulong addRef();
+ ulong release();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+
+ Preference *preference();
+ void connectTo( QUnknownInterface * ) {}
+ void deletePreferenceObject( Preference * );
+
+private:
+ QUnknownInterface *parent;
+ int ref;
+ QWidget *cppEditorSyntax;
+
+};
+
+#endif
+
diff --git a/tools/designer/plugins/cppeditor/projectsettings.ui b/tools/designer/plugins/cppeditor/projectsettings.ui
new file mode 100644
index 0000000..d5d9d87
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QUnknownInterface;</forward>
+<variable>QMap&lt;QString, QString&gt; config, libs, defines, includes;</variable>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+<widget class="QWidget">
+ <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="QLabel" 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="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>TextLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Defines:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="3" column="2">
+ <property name="name">
+ <cstring>editDefines</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Libs:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>TextLabel2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Includepath:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" 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="QComboBox" 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="QLineEdit" row="4" column="2">
+ <property name="name">
+ <cstring>editInclude</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="2">
+ <property name="name">
+ <cstring>editLibs</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="2">
+ <property name="name">
+ <cstring>editConfig</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox" 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="QComboBox" 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="QLabel" 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="QComboBox" 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 QString&amp;)</signal>
+ <receiver>CppProjectSettings</receiver>
+ <slot>configPlatformChanged(const QString&amp;)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>comboLibs</sender>
+ <signal>activated(const QString&amp;)</signal>
+ <receiver>CppProjectSettings</receiver>
+ <slot>libsPlatformChanged(const QString&amp;)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>comboDefines</sender>
+ <signal>activated(const QString&amp;)</signal>
+ <receiver>CppProjectSettings</receiver>
+ <slot>definesPlatformChanged(const QString&amp;)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>editConfig</sender>
+ <signal>textChanged(const QString&amp;)</signal>
+ <receiver>CppProjectSettings</receiver>
+ <slot>configChanged(const QString&amp;)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>editLibs</sender>
+ <signal>textChanged(const QString&amp;)</signal>
+ <receiver>CppProjectSettings</receiver>
+ <slot>libsChanged(const QString&amp;)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>editDefines</sender>
+ <signal>textChanged(const QString&amp;)</signal>
+ <receiver>CppProjectSettings</receiver>
+ <slot>definesChanged(const QString&amp;)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>editInclude</sender>
+ <signal>textChanged(const QString&amp;)</signal>
+ <receiver>CppProjectSettings</receiver>
+ <slot>includesChanged(const QString&amp;)</slot>
+ </connection>
+ <connection language="C++">
+ <sender>comboInclude</sender>
+ <signal>activated(const QString&amp;)</signal>
+ <receiver>CppProjectSettings</receiver>
+ <slot>includesPlatformChanged(const QString&amp;)</slot>
+ </connection>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">reInit( QUnknownInterface * iface )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">save( QUnknownInterface * iface )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">configChanged( const QString &amp; str )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">libsChanged( const QString &amp; str )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">definesChanged( const QString &amp; str )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">includesChanged( const QString &amp; str )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">configPlatformChanged( const QString &amp; plat )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">libsPlatformChanged( const QString &amp; plat )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">definesPlatformChanged( const QString &amp; plat )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">includesPlatformChanged( const QString &amp; 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 0000000..f5de0b7
--- /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 Qt Designer whenever you add, rename or
+** remove custom slots. Implementation code does not get lost.
+*****************************************************************************/
+
+#include <designerinterface.h>
+
+void CppProjectSettings::reInit( QUnknownInterface *iface )
+{
+ comboConfig->setCurrentItem( 0 );
+ comboLibs->setCurrentItem( 0 );
+ comboDefines->setCurrentItem( 0 );
+ comboInclude->setCurrentItem( 0 );
+
+ DesignerInterface *dIface = 0;
+ iface->queryInterface( IID_Designer, (QUnknownInterface**)&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 QString platforms[] = { "(all)", "win32", "unix", "mac", QString::null };
+ for ( int i = 0; platforms[ i ] != QString::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( QUnknownInterface *iface )
+{
+ DesignerInterface *dIface = 0;
+ iface->queryInterface( IID_Designer, (QUnknownInterface**)&dIface );
+ if ( !dIface )
+ return;
+ DesignerProject *project = dIface->currentProject();
+
+ project->setTemplate( comboTemplate->currentText() );
+ const QString platforms[] = { "(all)", "win32", "unix", "mac", QString::null };
+ for ( int i = 0; platforms[ i ] != QString::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 QString &str )
+{
+ config.replace( comboConfig->currentText(), str );
+}
+
+void CppProjectSettings::libsChanged( const QString &str )
+{
+ libs.replace( comboLibs->currentText(), str );
+}
+
+void CppProjectSettings::definesChanged( const QString &str )
+{
+ defines.replace( comboDefines->currentText(), str );
+}
+
+void CppProjectSettings::includesChanged( const QString &str )
+{
+ includes.replace( comboInclude->currentText(), str );
+}
+
+void CppProjectSettings::configPlatformChanged( const QString &plat )
+{
+ editConfig->setText( config[ plat ] );
+}
+
+void CppProjectSettings::libsPlatformChanged( const QString &plat )
+{
+ editLibs->setText( libs[ plat ] );
+}
+
+void CppProjectSettings::definesPlatformChanged( const QString &plat )
+{
+ editDefines->setText( defines[ plat ] );
+}
+
+void CppProjectSettings::includesPlatformChanged( const QString &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 0000000..9bb5d51
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QUnknownInterface *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( QUnknownInterface * ) );
+ pf->accept_slot = SLOT( save( QUnknownInterface * ) );
+ return pf;
+}
+
+QStringList ProjectSettingsInterfaceImpl::projectSettings() const
+{
+ return QStringList();
+}
+
+void ProjectSettingsInterfaceImpl::connectTo( QUnknownInterface * )
+{
+}
+
+void ProjectSettingsInterfaceImpl::deleteProjectSettingsObject( ProjectSettings *pf )
+{
+ delete pf;
+}
+
+QRESULT ProjectSettingsInterfaceImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ if ( parent )
+ return parent->queryInterface( uuid, iface );
+
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)this;
+ else if ( uuid == IID_ProjectSettings )
+ *iface = (ProjectSettingsInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_OK;
+}
diff --git a/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h b/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h
new file mode 100644
index 0000000..0cd0f45
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QUnknownInterface *outer = 0 );
+
+ ulong addRef();
+ ulong release();
+
+ ProjectSettings *projectSetting();
+ QStringList projectSettings() const;
+ void connectTo( QUnknownInterface *appInterface );
+ void deleteProjectSettingsObject( ProjectSettings * );
+ QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface );
+
+private:
+ QUnknownInterface *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 0000000..a158e81
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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()
+{
+}
+
+QRESULT SourceTemplateInterfaceImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)this;
+ else if ( uuid == IID_QFeatureList )
+ *iface = (QFeatureListInterface*)this;
+ else if ( uuid == IID_SourceTemplate )
+ *iface = (SourceTemplateInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+QStringList SourceTemplateInterfaceImpl::featureList() const
+{
+ QStringList l;
+ l << "C++ Main-File (main.cpp)";
+ return l;
+}
+
+static QString generateMainCppCode( const QString &formname, const QString &include )
+{
+ QString code;
+ code += "#include <qapplication.h>\n";
+ code += "#include \"" + include + "\"\n";
+ code += "\n";
+ code += "int main( int argc, char ** argv )\n";
+ code += "{\n";
+ code += " QApplication a( argc, argv );\n";
+ code += " " + formname + " w;\n";
+ code += " w.show();\n";
+ code += " a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );\n";
+ code += " return a.exec();\n";
+ code += "}\n";
+ return code;
+}
+
+SourceTemplateInterface::Source SourceTemplateInterfaceImpl::create( const QString &templ,
+ QUnknownInterface *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() == QDialog::Accepted ) {
+ DesignerInterface *dIface = 0;
+ appIface->queryInterface( IID_Designer, (QUnknownInterface**)&dIface );
+ if ( dIface ) {
+ src.type = SourceTemplateInterface::Source::FileName;
+ src.filename = dia.editFileName->text();
+ QString 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;
+}
+
+QString SourceTemplateInterfaceImpl::language( const QString & ) const
+{
+ return "C++";
+}
diff --git a/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h b/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h
new file mode 100644
index 0000000..52ae2d6
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ QStringList featureList() const;
+ Source create( const QString &templ, QUnknownInterface *appIface );
+ QString language( const QString &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 0000000..1b0a617
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 Qt
+ "slots",
+ "signals",
+ "uint",
+ "ushort",
+ "ulong",
+ "emit",
+ // end of array
+ 0
+};
+
+static QMap<int, QMap<QString, int > > *wordMap = 0;
+
+SyntaxHighlighter_CPP::SyntaxHighlighter_CPP()
+ : QTextPreProcessor(), lastFormat( 0 ), lastFormatId( -1 )
+{
+ QFont f( qApp->font() );
+
+ addFormat( Standard, new QTextFormat( f, Qt::black ) );
+ addFormat( Number, new QTextFormat( f, Qt::darkBlue ) );
+ addFormat( String, new QTextFormat( f, Qt::darkGreen ) );
+ addFormat( Type, new QTextFormat( f, Qt::darkMagenta ) );
+ addFormat( Keyword, new QTextFormat( f, Qt::darkYellow ) );
+ addFormat( PreProcessor, new QTextFormat( f, Qt::darkBlue ) );
+ addFormat( Label, new QTextFormat( f, Qt::darkRed ) );
+ f.setFamily( "times" );
+ addFormat( Comment, new QTextFormat( f, Qt::red ) );
+
+ if ( wordMap )
+ return;
+
+ wordMap = new QMap<int, QMap<QString, int> >;
+ int len;
+ for ( int i = 0; keywords[ i ]; ++i ) {
+ len = (int)strlen( keywords[ i ] );
+ if ( !wordMap->contains( len ) )
+ wordMap->insert( len, QMap<QString, int >() );
+ QMap<QString, int> &map = wordMap->operator[]( len );
+ map[ keywords[ i ] ] = Keyword;
+ }
+}
+
+SyntaxHighlighter_CPP::~SyntaxHighlighter_CPP()
+{
+}
+
+static int string2Id( const QString &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 QMap<QString, ConfigStyle> &styles )
+{
+ for ( QMap<QString, ConfigStyle>::ConstIterator it = styles.begin(); it != styles.end(); ++it ) {
+ int id = string2Id( it.key() );
+ QTextFormat *f = format( id );
+ if ( !f )
+ continue;
+ f->setFont( (*it).font );
+ f->setColor( (*it).color );
+ }
+}
+
+void SyntaxHighlighter_CPP::process( QTextDocument *doc, QTextParagraph *string, int, bool invalidate )
+{
+
+ QTextFormat *formatStandard = format( Standard );
+ QTextFormat *formatComment = format( Comment );
+ QTextFormat *formatNumber = format( Number );
+ QTextFormat *formatString = format( String );
+ QTextFormat *formatType = format( Type );
+ QTextFormat *formatPreProcessor = format( PreProcessor );
+ QTextFormat *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
+ };
+
+ QString 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;
+
+ QString alphabeth = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QString mathChars = "xXeE";
+ QString numbers = "0123456789";
+ bool questionMark = FALSE;
+ QChar lastChar;
+ for (;;) {
+ QChar 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;
+ QChar 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 {
+ QMap<int, QMap<QString, int > >::Iterator it = wordMap->find( len );
+ if ( it != wordMap->end() ) {
+ QMap<QString, int >::Iterator it2 = ( *it ).find( buffer );
+ if ( it2 != ( *it ).end() )
+ string->setFormat( i - buffer.length(), buffer.length(), format( ( *it2 ) ), FALSE );
+ }
+ }
+ buffer = QString::null;
+ }
+ } break;
+ case StateCommentStart1:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = TRUE;
+ buffer = QString::null;
+ break;
+ case StateCCommentStart2:
+ string->setFormat( i - 1, 2, formatComment, FALSE );
+ makeLastStandard = FALSE;
+ buffer = QString::null;
+ break;
+ case StateCppCommentStart2:
+ string->setFormat( i - 1, 2, formatComment, FALSE );
+ makeLastStandard = FALSE;
+ buffer = QString::null;
+ break;
+ case StateCComment:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatComment, FALSE );
+ buffer = QString::null;
+ break;
+ case StateCppComment:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatComment, FALSE );
+ buffer = QString::null;
+ break;
+ case StateCCommentEnd1:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatComment, FALSE );
+ buffer = QString::null;
+ break;
+ case StateCCommentEnd2:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatComment, FALSE );
+ buffer = QString::null;
+ break;
+ case StateStringStart:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatStandard, FALSE );
+ buffer = QString::null;
+ break;
+ case StateString:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatString, FALSE );
+ buffer = QString::null;
+ break;
+ case StateStringEnd:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatStandard, FALSE );
+ buffer = QString::null;
+ break;
+ case StateString2Start:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatStandard, FALSE );
+ buffer = QString::null;
+ break;
+ case StateString2:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatString, FALSE );
+ buffer = QString::null;
+ break;
+ case StateString2End:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatStandard, FALSE );
+ buffer = QString::null;
+ break;
+ case StateNumber:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatNumber, FALSE );
+ buffer = QString::null;
+ break;
+ case StatePreProcessor:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatPreProcessor, FALSE );
+ buffer = QString::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 );
+
+ QTextParagraph *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();
+ }
+ }
+}
+
+QTextFormat *SyntaxHighlighter_CPP::format( int id )
+{
+ if ( lastFormatId == id && lastFormat )
+ return lastFormat;
+
+ QTextFormat *f = formats[ id ];
+ lastFormat = f ? f : formats[ 0 ];
+ lastFormatId = id;
+ return lastFormat;
+}
+
+void SyntaxHighlighter_CPP::addFormat( int id, QTextFormat *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 0000000..ea973d9
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QCPPSYNTAXHIGHLIGHTER_H
+#define QCPPSYNTAXHIGHLIGHTER_H
+
+#include <private/qrichtext_p.h>
+#include <conf.h>
+
+class SyntaxHighlighter_CPP : public QTextPreProcessor
+{
+public:
+ enum CppIds {
+ Comment = 1,
+ Number,
+ String,
+ Type,
+ Keyword,
+ PreProcessor,
+ Label
+ };
+
+ SyntaxHighlighter_CPP();
+ virtual ~SyntaxHighlighter_CPP();
+ void process( QTextDocument *doc, QTextParagraph *string, int start, bool invalidate = TRUE );
+ void updateStyles( const QMap<QString, ConfigStyle> &styles );
+
+ static const char * const keywords[];
+
+ QTextFormat *format( int id );
+
+private:
+ void addFormat( int id, QTextFormat *f );
+ void removeFormat( int id );
+
+ QTextFormat *lastFormat;
+ int lastFormatId;
+ QIntDict<QTextFormat> formats;
+
+};
+
+#endif
diff --git a/tools/designer/plugins/cppeditor/yyreg.cpp b/tools/designer/plugins/cppeditor/yyreg.cpp
new file mode 100644
index 0000000..144c99f
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString *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 QString& in )
+{
+ yyIn = new QString;
+ *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 quick-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( QChar('\n'), yyCurPos ) + 1;
+ QString line = yyIn->mid( lineStart,
+ yyCurPos - lineStart + 2 );
+ int commentStart = line.find( QString("//") );
+ 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.
+*/
+QString CppFunction::prototype() const
+{
+ QString proto;
+
+ if ( !returnType().isEmpty() )
+ proto = returnType() + QChar( ' ' );
+ proto += scopedName();
+ proto += QChar( '(' );
+ if ( !parameterList().isEmpty() ) {
+ QStringList::ConstIterator p = parameterList().begin();
+ proto += *p;
+ ++p;
+ while ( p != parameterList().end() ) {
+ proto += QString( ", " );
+ proto += *p;
+ ++p;
+ }
+ }
+ proto += QChar( ')' );
+ if ( isConst() )
+ proto += QString( " 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 QString& thingy )
+{
+ // e.g., Alpha<a>::Beta<Bar<b, c> >::~Beta
+ QRegExp xtor( QString(
+ "(?:([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: QMap < QString , QValueList < QString > > @ m ;
+ After: QMap @ < QString , QValueList < QString > > m ;
+*/
+static QString matchTemplateAngles()
+{
+ QString 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 QString matchArrayBrackets()
+{
+ QString t;
+
+ while ( yyTok == Tok_RightBracket ) {
+ t.prepend( yyLex );
+ yyTok = getToken();
+ if ( yyTok == Tok_Something ) {
+ t.prepend( yyLex );
+ yyTok = getToken();
+ }
+ if ( yyTok != Tok_LeftBracket )
+ return QString::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( QString *type, const QString& prefix )
+{
+ if ( !type->isEmpty() && !prefix.isEmpty() ) {
+ QChar left = prefix[(int) prefix.length() - 1];
+ QChar right = (*type)[0];
+
+ if ( left.isLetter() &&
+ (right.isLetter() || right == QChar('*') || right == QChar('&')) )
+ type->prepend( QChar(' ') );
+ }
+ 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 QString matchDataType()
+{
+ QString 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 QString::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
+ QString documentation;
+#endif
+ QString returnType;
+ QString scopedName;
+ QStringList params;
+ QString 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 ( ;; ) {
+ QString brackets = matchArrayBrackets();
+ QString name;
+ if ( yyTok == Tok_Ident ) {
+ name = yyLex;
+ yyTok = getToken();
+ }
+ QString type = matchDataType();
+
+ if ( type.isEmpty() ) {
+ if ( name.isEmpty() )
+ return func;
+ type = name;
+ name = QString::null;
+ }
+ if ( stripParamNames )
+ name = QString::null;
+
+ QString param = type + QChar( ' ' ) + 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 require no
+ special processing.
+*/
+static void setBody( CppFunction *func, const QString& somewhatBody )
+{
+ QString body = somewhatBody;
+
+ int braceDepth = 0;
+ int i = 0;
+ while ( i < (int) body.length() ) {
+ if ( body[i] == QChar('{') ) {
+ braceDepth++;
+ } else if ( body[i] == QChar('}') ) {
+ 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( QValueList<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() ) {
+ QString body = yyIn->mid( startBody, endBody - startBody );
+ setBody( &func, body );
+ body = func.body(); // setBody() can change the body
+
+ /*
+ Compute important line numbers.
+ */
+ int functionStartLineNo = 1 + QConstString( yyIn->unicode(), yyPos )
+ .string().contains( QChar('\n') );
+ int startLineNo = functionStartLineNo +
+ QConstString( yyIn->unicode() + yyPos, startBody - yyPos )
+ .string().contains( QChar('\n') );
+ int endLineNo = startLineNo + body.contains( QChar('\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 QString& code, QValueList<CppFunction> *flist )
+{
+ startTokenizer( code );
+ yyTok = getToken();
+ matchTranslationUnit( flist );
+ stopTokenizer();
+}
+
+/*
+ Returns the prototype with the parameter names removed.
+*/
+QString canonicalCppProto( const QString& 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 0000000..f75c948
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString& r ) { ret = r; }
+ void setScopedName( const QString& n ) { nam = n; }
+ void setParameterList( const QStringList& p ) { params = p; }
+ void setConst( bool c ) { cnst = c; }
+ void setBody( const QString& b ) { bod = b; }
+ void setDocumentation( const QString& d ) { doc = d; }
+ void setLineNums( int functionStart, int openingBrace, int closingBrace ) {
+ lineno0 = functionStart;
+ lineno1 = openingBrace;
+ lineno2 = closingBrace;
+ }
+
+ const QString& returnType() const { return ret; }
+ const QString& scopedName() const { return nam; }
+ const QStringList& parameterList() const { return params; }
+ bool isConst() const { return cnst; }
+ QString prototype() const;
+ const QString& body() const { return bod; }
+ const QString& 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:
+ QString ret;
+ QString nam;
+ QStringList params;
+ bool cnst;
+ QString bod;
+ QString doc;
+ int lineno0;
+ int lineno1;
+ int lineno2;
+};
+
+void extractCppFunctions( const QString& code, QValueList<CppFunction> *flist );
+QString canonicalCppProto( const QString& proto );
+
+#endif
diff --git a/tools/designer/plugins/dlg/dlg.pro b/tools/designer/plugins/dlg/dlg.pro
new file mode 100644
index 0000000..ee93cb9
--- /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 0000000..c309eb2
--- /dev/null
+++ b/tools/designer/plugins/dlg/dlg2ui.cpp
@@ -0,0 +1,1632 @@
+/**********************************************************************
+**
+** Converts a Qt Architect 2.1+ .dlg file into a .ui file.
+**
+** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 Qt Designer supports the latter.
+*/
+
+/*
+ These big tables could be more or less eliminated by using Qt's
+ QMetaObject and QMetaProperty 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 QObject
+ subclasses in Qt. 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 Qt Architect properties to Qt Designer properties.
+ If there is no corresponding Qt 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 QString& val )
+{
+ return val.lower() == QString( "true" );
+}
+
+static AttributeMap attribute( const QString& name, const QString& val )
+{
+ AttributeMap attr;
+ attr.insert( name, val );
+ return attr;
+}
+
+static QString entitize( const QString& str )
+{
+ QString t = str;
+ t.replace( '&', QString("&amp;") );
+ t.replace( '>', QString("&gt;") );
+ t.replace( '<', QString("&lt;") );
+ t.replace( '"', QString("&quot;") );
+ t.replace( '\'', QString("&apos;") );
+ return t;
+}
+
+QString Dlg2Ui::alias( const QString& name ) const
+{
+ if ( yyAliasMap.contains(name) )
+ return yyAliasMap[name];
+ else
+ return name;
+}
+
+QString Dlg2Ui::opening( const QString& tag, const AttributeMap& attr )
+{
+ QString t = QChar( '<' ) + tag;
+ AttributeMap::ConstIterator a = attr.begin();
+ while ( a != attr.end() ) {
+ t += QChar( ' ' ) + a.key() + QString( "=\"" ) + entitize( *a ) +
+ QChar( '"' );
+ ++a;
+ }
+ t += QChar( '>' );
+ return t;
+}
+
+QString Dlg2Ui::closing( const QString& tag )
+{
+ return opening( QChar('/') + tag );
+}
+
+void Dlg2Ui::error( const QString& message )
+{
+ if ( numErrors++ == 0 )
+ QMessageBox::warning( 0, yyFileName, message );
+}
+
+void Dlg2Ui::syntaxError()
+{
+ error( QString("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.") );
+}
+
+QString Dlg2Ui::getTextValue( const QDomNode& node )
+{
+ if ( node.childNodes().count() > 1 ) {
+ syntaxError();
+ return QString::null;
+ }
+
+ if ( node.childNodes().count() == 0 )
+ return QString::null;
+
+ QDomText child = node.firstChild().toText();
+ if ( child.isNull() ) {
+ syntaxError();
+ return QString::null;
+ }
+ QString t = child.data().stripWhiteSpace();
+ t.replace( "\\\\", "\\" );
+ t.replace( "\\n", "\n" );
+ return t;
+}
+
+QVariant Dlg2Ui::getValue( const QDomNodeList& children, const QString& tagName,
+ const QString& type )
+{
+ for ( int i = 0; i < (int) children.count(); i++ ) {
+ QDomNode n = children.item( i );
+ if ( n.toElement().tagName() == tagName )
+ return getValue( n.toElement(), tagName, type );
+ }
+ return QVariant();
+}
+
+void Dlg2Ui::emitHeader()
+{
+ yyOut += QString( "<!DOCTYPE UI><UI version=\"3.0\" stdsetdef=\"1\">\n" );
+}
+
+void Dlg2Ui::emitFooter()
+{
+ yyOut += QString( "</UI>\n" );
+}
+
+void Dlg2Ui::emitSimpleValue( const QString& tag, const QString& value,
+ const AttributeMap& attr )
+{
+ yyOut += yyIndentStr + opening( tag, attr ) + entitize( value ) +
+ closing( tag ) + QChar( '\n' );
+}
+
+void Dlg2Ui::emitOpening( const QString& tag, const AttributeMap& attr )
+{
+ yyOut += yyIndentStr + opening( tag, attr ) + QChar( '\n' );
+ yyIndentStr += QString( " " );
+}
+
+void Dlg2Ui::emitClosing( const QString& tag )
+{
+ yyIndentStr.truncate( yyIndentStr.length() - 4 );
+ yyOut += yyIndentStr + closing( tag ) + QChar( '\n' );
+}
+
+void Dlg2Ui::emitOpeningWidget( const QString& className )
+{
+ AttributeMap attr = attribute( QString("class"), className );
+ if ( yyGridColumn >= 0 ) {
+ attr.insert( QString("row"), QString::number(yyGridRow) );
+ attr.insert( QString("column"), QString::number(yyGridColumn) );
+ yyGridColumn = -1;
+ }
+ emitOpening( QString("widget"), attr );
+}
+
+QString Dlg2Ui::widgetClassName( const QDomElement& e )
+{
+ if ( e.tagName() == QString("User") ) {
+ return getValue( e.childNodes(), QString("UserClassName") )
+ .toString();
+ } else if ( e.tagName() == QString("DlgWidget") ) {
+ return QString( "QWidget" );
+ } else {
+ return QChar( 'Q' ) + e.tagName();
+ }
+}
+
+void Dlg2Ui::emitColor( const QColor& color )
+{
+ emitOpening( QString("color") );
+ emitSimpleValue( QString("red"), QString::number(color.red()) );
+ emitSimpleValue( QString("green"), QString::number(color.green()) );
+ emitSimpleValue( QString("blue"), QString::number(color.blue()) );
+ emitClosing( QString("color") );
+}
+
+void Dlg2Ui::emitColorGroup( const QString& name, const QColorGroup& group )
+{
+ emitOpening( name );
+ for ( int i = 0; i < NumColorRoles; i++ )
+ emitColor( group.color((QColorGroup::ColorRole) i) );
+ emitClosing( name );
+}
+
+void Dlg2Ui::emitVariant( const QVariant& val, const QString& stringType )
+{
+ if ( val.isValid() ) {
+ switch ( val.type() ) {
+ case QVariant::String:
+ emitSimpleValue( stringType, val.toString() );
+ break;
+ case QVariant::CString:
+ emitSimpleValue( QString("cstring"), val.toString() );
+ break;
+ case QVariant::Bool:
+ emitSimpleValue( QString("bool"),
+ QString(val.toBool() ? "true" : "false") );
+ break;
+ case QVariant::Int:
+ case QVariant::UInt:
+ emitSimpleValue( QString("number"), val.toString() );
+ break;
+ case QVariant::Rect:
+ emitOpening( QString("rect") );
+ emitSimpleValue( QString("x"), QString::number(val.toRect().x()) );
+ emitSimpleValue( QString("y"), QString::number(val.toRect().y()) );
+ emitSimpleValue( QString("width"),
+ QString::number(val.toRect().width()) );
+ emitSimpleValue( QString("height"),
+ QString::number(val.toRect().height()) );
+ emitClosing( QString("rect") );
+ break;
+ case QVariant::Point:
+ emitOpening( QString("point") );
+ emitSimpleValue( QString("x"), QString::number(val.toPoint().x()) );
+ emitSimpleValue( QString("y"), QString::number(val.toPoint().y()) );
+ emitClosing( QString("point") );
+ break;
+ case QVariant::Size:
+ emitOpening( QString("size") );
+ emitSimpleValue( QString("width"),
+ QString::number(val.toSize().width()) );
+ emitSimpleValue( QString("height"),
+ QString::number(val.toSize().height()) );
+ emitClosing( QString("size") );
+ break;
+ case QVariant::Color:
+ emitColor( val.toColor() );
+ break;
+ case QVariant::Font:
+ emitOpening( QString("font") );
+ emitSimpleValue( QString("family"), val.toFont().family() );
+ emitSimpleValue( QString("pointsize"),
+ QString::number(val.toFont().pointSize()) );
+ if ( val.toFont().bold() )
+ emitSimpleValue( QString("bold"), QChar('1') );
+ if ( val.toFont().italic() )
+ emitSimpleValue( QString("italic"), QChar('1') );
+ if ( val.toFont().underline() )
+ emitSimpleValue( QString("underline"), QChar('1') );
+ if ( val.toFont().strikeOut() )
+ emitSimpleValue( QString("strikeout"), QChar('1') );
+ emitClosing( QString("font") );
+ break;
+ case QVariant::Palette:
+ emitOpening( QString("palette") );
+ emitColorGroup( QString("active"), val.toPalette().active() );
+ emitColorGroup( QString("disabled"), val.toPalette().disabled() );
+ emitColorGroup( QString("inactive"), val.toPalette().inactive() );
+ emitClosing( QString("palette") );
+ break;
+ default:
+ emitSimpleValue( QString("fnord"), QString::null );
+ }
+ }
+}
+
+void Dlg2Ui::emitProperty( const QString& prop, const QVariant& val,
+ const QString& stringType )
+{
+ emitOpening( QString("property"), attribute(QString("name"), prop) );
+ emitVariant( val, stringType );
+ emitClosing( QString("property") );
+}
+
+void Dlg2Ui::emitAttribute( const QString& attr, const QVariant& val,
+ const QString& stringType )
+{
+ emitOpening( QString("attribute"), attribute(QString("name"), attr) );
+ emitVariant( val, stringType );
+ emitClosing( QString("attribute") );
+}
+
+void Dlg2Ui::emitOpeningLayout( bool needsWidget, const QString& layoutKind,
+ const QString& name, int border,
+ int autoBorder )
+{
+ QString namex = name;
+
+ if ( namex.isEmpty() )
+ namex = QString( "Layout%1" ).arg( uniqueLayout++ );
+
+ if ( needsWidget ) {
+ emitOpeningWidget( QString("QLayoutWidget") );
+ emitProperty( QString("name"), namex.latin1() );
+ }
+ emitOpening( layoutKind );
+ if ( !needsWidget )
+ emitProperty( QString("name"), namex.latin1() );
+ if ( border != 5 )
+ emitProperty( QString("margin"), border );
+ if ( autoBorder != 5 )
+ emitProperty( QString("spacing"), autoBorder );
+ yyLayoutDepth++;
+}
+
+void Dlg2Ui::flushWidgets()
+{
+ QRegExp widgetForLayout( QString("Q(?:[HV]Box|Grid)") );
+
+ while ( !yyWidgetMap.isEmpty() ) {
+ QString className = widgetClassName( *yyWidgetMap.begin() );
+ if ( !widgetForLayout.exactMatch(className) ) {
+ emitOpeningWidget( className );
+ emitWidgetBody( *yyWidgetMap.begin(), FALSE );
+ emitClosing( QString("widget") );
+ }
+ yyWidgetMap.remove( yyWidgetMap.begin() );
+ }
+}
+
+void Dlg2Ui::emitClosingLayout( bool needsWidget, const QString& layoutKind )
+{
+ yyLayoutDepth--;
+ /*
+ Qt 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 Qt Designer.
+ */
+ if ( yyLayoutDepth == 0 )
+ flushWidgets();
+
+ emitClosing( layoutKind );
+ if ( needsWidget )
+ emitClosing( QString("widget") );
+}
+
+bool Dlg2Ui::isWidgetType( const QDomElement& e )
+{
+ return yyWidgetTypeSet.contains( e.tagName() );
+}
+
+void Dlg2Ui::emitSpacer( int spacing, int stretch )
+{
+ QString orientationStr;
+ QSize sizeHint;
+ QString sizeType = QString( "Fixed" );
+
+ if ( yyBoxKind == QString("hbox") ) {
+ orientationStr = QString( "Horizontal" );
+ sizeHint = QSize( spacing, 20 );
+ } else {
+ orientationStr = QString( "Vertical" );
+ sizeHint = QSize( 20, spacing );
+ }
+ if ( stretch > 0 )
+ sizeType = QString( "Expanding" );
+
+ emitOpening( QString("spacer") );
+ emitProperty( QString("name"),
+ QString("Spacer%1").arg(uniqueSpacer++).latin1() );
+ emitProperty( QString("orientation"), orientationStr, QString("enum") );
+ if ( spacing > 0 )
+ emitProperty( QString("sizeHint"), sizeHint, QString("qsize") );
+ emitProperty( QString("sizeType"), sizeType, QString("enum") );
+ emitClosing( QString("spacer") );
+}
+
+QString Dlg2Ui::filteredFlags( const QString& flags, const QRegExp& filter )
+{
+ QRegExp evil( QString("[^0-9A-Z_a-z|]") );
+
+ QString f = flags;
+ f.replace( evil, QString::null );
+ QStringList splitted = QStringList::split( QChar('|'), f );
+ return splitted.grep( filter ).join( QChar('|') );
+}
+
+void Dlg2Ui::emitFrameStyleProperty( int style )
+{
+ QString shape;
+ QString shadow;
+
+ switch ( style & QFrame::MShape ) {
+ case QFrame::Box:
+ shape = QString( "Box" );
+ break;
+ case QFrame::Panel:
+ shape = QString( "Panel" );
+ break;
+ case QFrame::WinPanel:
+ shape = QString( "WinPanel" );
+ break;
+ case QFrame::HLine:
+ shape = QString( "HLine" );
+ break;
+ case QFrame::VLine:
+ shape = QString( "VLine" );
+ break;
+ case QFrame::StyledPanel:
+ shape = QString( "StyledPanel" );
+ break;
+ case QFrame::PopupPanel:
+ shape = QString( "PopupPanel" );
+ break;
+ case QFrame::MenuBarPanel:
+ shape = QString( "MenuBarPanel" );
+ break;
+ case QFrame::ToolBarPanel:
+ shape = QString( "ToolBarPanel" );
+ break;
+ case QFrame::LineEditPanel:
+ shape = QString( "LineEditPanel" );
+ break;
+ case QFrame::TabWidgetPanel:
+ shape = QString( "TabWidgetPanel" );
+ break;
+ case QFrame::GroupBoxPanel:
+ shape = QString( "GroupBoxPanel" );
+ break;
+ default:
+ shape = QString( "NoFrame" );
+ }
+
+ switch ( style & QFrame::MShadow ) {
+ case QFrame::Raised:
+ shadow = QString( "Raised" );
+ break;
+ case QFrame::Sunken:
+ shadow = QString( "Sunken" );
+ break;
+ default:
+ shadow = QString( "Plain" );
+ }
+
+ emitProperty( QString("frameShape"), shape, QString("enum") );
+ emitProperty( QString("frameShadow"), shadow, QString("enum") );
+}
+
+void Dlg2Ui::emitWidgetBody( const QDomElement& e, bool layouted )
+{
+ QRegExp align( QString("^(?:Align|WordBreak$)") );
+ QRegExp frameShape( QString(
+ "^(?:NoFrame|Box|(?:Win|Styled|Popup|(?:Menu|Tool)Bar)?Panel|"
+ "[HV]Line)$") );
+ QRegExp frameShadow( QString( "^(?:Plain|Raised|Sunken)$") );
+ QRegExp numeric( QString("[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+") );
+ QRegExp connex( QString(
+ "\\s*\\[(BaseClass|P(?:ublic|rotected))\\]\\s*([0-9A-Z_a-z]+)\\s*"
+ "-->\\s*([0-9A-Z_a-z]+)\\s*(\\([^()]*\\))\\s*") );
+ QRegExp qdialogSlots( QString(
+ "done\\(\\s*int\\s*\\)|(?:accept|reject)\\(\\s*\\)") );
+
+ QString userClassHeader;
+ QString userClassName;
+ QString parentTagName;
+ QString name;
+ QString variableName;
+ QMap<QString, int> pp;
+
+ QDomNode n = e;
+ while ( !n.isNull() ) {
+ if ( isWidgetType(n.toElement()) ) {
+ parentTagName = n.toElement().tagName();
+ pp = yyPropertyMap[parentTagName];
+ n = n.firstChild();
+ } else {
+ QString tagName = n.toElement().tagName();
+
+ QMap<QString, 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 == QString("Alignement") ||
+ tagName == QString("Alignment") ) {
+ QString flags = getValue( n.toElement(), tagName )
+ .toString();
+ flags = filteredFlags( flags, align );
+ if ( !flags.isEmpty() )
+ emitProperty( QString("alignment"), flags,
+ QString("set") );
+ } else if ( tagName == QString("ItemList") ) {
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ if ( child.toElement().tagName() == QString("Item") ) {
+ QString text = getTextValue( child );
+ emitOpening( QString("item") );
+ emitProperty( QString("text"), text );
+ emitClosing( QString("item") );
+ }
+ child = child.nextSibling();
+ }
+ }
+ } else {
+ QString propertyName( propertyDefs[*p].qtName );
+
+ if ( propertyName.isEmpty() ) {
+ /*
+ These properties are in the propertyDefs table,
+ but they have no direct Qt equivalent.
+ */
+ if ( parentTagName == QString("ComboBox") ) {
+ if ( tagName == QString("Style") ) {
+ if ( getTextValue(n) == QString("ReadWrite") )
+ emitProperty( QString("editable"),
+ QVariant(TRUE, 0) );
+ }
+ } else if ( parentTagName == QString("DlgWidget") ) {
+ if ( tagName == QString("Name") ) {
+ name = getTextValue( n );
+ } else if ( tagName == QString("Rect") ) {
+ QRect rect = getValue( n.toElement(), tagName,
+ QString("qrect") )
+ .toRect();
+ if ( !layouted )
+ emitProperty( QString("geometry"), rect,
+ QString("qrect") );
+ } else if ( tagName == QString("SignalConnection") ) {
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ if ( child.toElement().tagName() ==
+ QString("Signal") ) {
+ QString text = getTextValue( child );
+ if ( connex.exactMatch(text) ) {
+ DlgConnection c;
+ c.sender = getValue(
+ n.parentNode().childNodes(),
+ QString("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) !=
+ QString("BaseClass") &&
+ !qdialogSlots.exactMatch(c.slot) )
+ yySlots.insert( c.slot,
+ connex.cap(1) );
+ }
+ }
+ child = child.nextSibling();
+ }
+ } else if ( tagName == QString("Variable") ) {
+ variableName = getTextValue( n );
+ }
+ } else if ( parentTagName == QString("Frame") ) {
+ if ( tagName == QString("Style") ) {
+ int style = getValue( n.toElement(), tagName,
+ QString("integer") ).toInt();
+ emitFrameStyleProperty( style );
+ }
+ } else if ( parentTagName == QString("LCDNumber") ) {
+ if ( tagName == QString("Value") ) {
+ QString text = getValue( n.toElement(), tagName )
+ .toString();
+ if ( numeric.exactMatch(text) )
+ emitProperty( QString("value"),
+ text.toDouble() );
+ }
+ } else if ( parentTagName == QString("ListView") ) {
+ if ( tagName == QString("HeaderInformation") ) {
+ int columnNo = 1;
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ if ( child.toElement().tagName() ==
+ QString("Header") ) {
+ QString text = getValue( child.childNodes(),
+ QString("Text") )
+ .toString();
+ if ( text.isEmpty() )
+ text = QString( "Column %1" )
+ .arg( columnNo );
+ emitOpening( QString("column") );
+ emitProperty( QString("text"), text );
+ emitClosing( QString("column") );
+ }
+ child = child.nextSibling();
+ columnNo++;
+ }
+ }
+ } else if ( parentTagName == QString("TabBar") ) {
+ if ( tagName == QString("TabNames") ) {
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ if ( child.toElement().tagName() ==
+ QString("Tab") ) {
+ QString text = getTextValue( child );
+ emitOpeningWidget( QString("QWidget") );
+ emitProperty( QString("name"), "tab" );
+ emitAttribute( QString("title"), text );
+ emitClosing( QString("widget") );
+ }
+ child = child.nextSibling();
+ }
+ }
+ } else if ( parentTagName == QString("User") ) {
+ if ( tagName == QString("UserClassHeader") ) {
+ userClassHeader = getTextValue( n );
+ } else if ( tagName == QString("UserClassName") ) {
+ userClassName = getTextValue( n );
+ }
+ }
+ } else {
+ /*
+ These properties are in the propertyDefs table;
+ they have a direct Qt equivalent.
+ */
+ QString type( propertyDefs[*p].type );
+ QVariant val = getValue( n.toElement(), tagName, type );
+
+ if ( type == QString("qstring") )
+ type = QString( "string" );
+
+ bool omit = FALSE;
+ if ( propertyName == QString("backgroundOrigin") &&
+ val.toString() == QString("WidgetOrigin") )
+ omit = TRUE;
+ if ( propertyName == QString("enabled") && val.toBool() )
+ omit = TRUE;
+ if ( propertyName == QString("minimumSize") &&
+ val.toSize() == QSize(-1, -1) )
+ omit = TRUE;
+ if ( propertyName == QString("maximumSize") &&
+ val.toSize() == QSize(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( QString("name"), name.latin1() );
+
+ if ( !userClassName.isEmpty() )
+ yyCustomWidgets.insert( userClassName, userClassHeader );
+}
+
+bool Dlg2Ui::checkTagName( const QDomElement& e, const QString& tagName )
+{
+ bool ok = ( e.tagName() == tagName );
+ if ( !ok )
+ syntaxError();
+ return ok;
+}
+
+QString Dlg2Ui::normalizeType( const QString& type )
+{
+ QString t = type;
+ if ( t.isEmpty() || t == QString("enum") || t == QString( "qcstring" ) ||
+ t == QString("set") )
+ t = QString( "qstring" );
+ return t;
+}
+
+QVariant Dlg2Ui::getValue( const QDomElement& e, const QString& tagName,
+ const QString& type )
+{
+ QVariant val;
+
+ if ( e.tagName() != tagName )
+ return val;
+
+ QString t = e.attributes().namedItem( "type" ).toAttr().value();
+ if ( normalizeType(t) != normalizeType(type) )
+ return val;
+
+ if ( type == QString("integer") ) {
+ return getTextValue( e ).toInt();
+ } else if ( type == QString("boolean") ) {
+ return QVariant( isTrue(getTextValue(e)), 0 );
+ } else if ( type == QString("double") ) {
+ return getTextValue( e ).toDouble();
+ } else if ( type == QString("qcstring") ) {
+ return getTextValue( e ).latin1();
+ } else if ( type == QString("enum") || type == QString("qstring") ||
+ type == QString("set") ) {
+ return getTextValue( e );
+ } else {
+ QDomNodeList children = e.childNodes();
+
+ if ( type == QString("qsize") ) {
+ int width = getValue( children, QString("Width"),
+ QString("integer") ).toInt();
+ int height = getValue( children, QString("Height"),
+ QString("integer") ).toInt();
+ return QSize( width, height );
+ } else if ( type == QString("qrect") ) {
+ int x = getValue( children, QString("X"), QString("integer") )
+ .toInt();
+ int y = getValue( children, QString("Y"), QString("integer") )
+ .toInt();
+ int width = getValue( children, QString("Width"),
+ QString("integer") ).toInt();
+ int height = getValue( children, QString("Height"),
+ QString("integer") ).toInt();
+ return QRect( x, y, width, height );
+ } else if ( type == QString("qpoint") ) {
+ int x = getValue( children, QString("X"), QString("integer") )
+ .toInt();
+ int y = getValue( children, QString("Y"), QString("integer") )
+ .toInt();
+ return QPoint( x, y );
+ } else if ( type == QString("qpalette") ) {
+ QColorGroup active = getValue( children, QString("Active"),
+ QString("qcolorgroup") )
+ .toColorGroup();
+ QColorGroup disabled = getValue( children, QString("Disabled"),
+ QString("qcolorgroup") )
+ .toColorGroup();
+ QColorGroup inactive = getValue( children, QString("Inactive"),
+ QString("qcolorgroup") )
+ .toColorGroup();
+ return QPalette( active, disabled, inactive );
+ } else if ( type == QString("qfont") ) {
+ QString family = getValue( children, QString("Family"),
+ QString("qstring") ).toString();
+ int pointSize = getValue( children, QString("PointSize"),
+ QString("integer") ).toInt();
+ int weight = getValue( children, QString("weight"),
+ QString("integer") ).toInt();
+ bool italic = getValue( children, QString("Italic"),
+ QString("boolean") ).toBool();
+ bool underline = getValue( children, QString("Underline"),
+ QString("boolean") ).toBool();
+ bool strikeOut = getValue( children, QString("StrikeOut"),
+ QString("boolean") ).toBool();
+ int styleHint = getValue( children, QString("StyleHint"),
+ QString("integer") ).toInt();
+
+ QFont 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( (QFont::StyleHint) styleHint );
+ return f;
+ } else if ( type == QString("qcolor") ) {
+ // if any component missing, zero is to be assumed
+ int red = getValue( children, QString("Red"), QString("integer") )
+ .toInt();
+ int green = getValue( children, QString("Green"),
+ QString("integer") ).toInt();
+ int blue = getValue( children, QString("Blue"), QString("integer") )
+ .toInt();
+ return QColor( red, green, blue );
+ } else if ( type == QString("qcolorgroup") ) {
+ static const QColorGroup::ColorRole roles[NumColorRoles] = {
+ QColorGroup::Foreground, QColorGroup::Button,
+ QColorGroup::Light, QColorGroup::Midlight, QColorGroup::Dark,
+ QColorGroup::Mid, QColorGroup::Text, QColorGroup::BrightText,
+ QColorGroup::ButtonText, QColorGroup::Base,
+ QColorGroup::Background, QColorGroup::Shadow,
+ QColorGroup::Highlight, QColorGroup::HighlightedText
+ };
+ static const char * const roleNames[NumColorRoles] = {
+ "Foreground", "Button", "Light", "MidLight", "Dark", "Mid",
+ "Text", "BrightText", "ButtonText", "Base", "Background",
+ "Shadow", "HighLighted", "HighLightedText"
+ };
+ QColorGroup group;
+
+ for ( int i = 0; i < NumColorRoles; i++ )
+ group.setColor( roles[i],
+ getValue(children, QString(roleNames[i]),
+ QString("qcolor")).toColor() );
+ return group;
+ } else {
+ syntaxError();
+ }
+ }
+ return val;
+}
+
+void Dlg2Ui::matchDialogCommon( const QDomElement& dialogCommon )
+{
+ if ( !checkTagName(dialogCommon, QString("DialogCommon")) )
+ return;
+
+ QString sourceDir;
+ QString classHeader;
+ QString classSource;
+ QString dataHeader;
+ QString dataSource;
+ QString dataName;
+ QString windowBaseClass( "QDialog" );
+ bool isCustom = FALSE;
+ QString customBaseHeader;
+ QString windowCaption;
+
+ yyClassName = "Form1";
+
+ QDomNode n = dialogCommon.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ QString val = getTextValue( n );
+
+ if ( tagName == QString("SourceDir") ) {
+ sourceDir = val;
+ } else if ( tagName == QString("ClassHeader") ) {
+ classHeader = val;
+ } else if ( tagName == QString("ClassSource") ) {
+ classSource = val;
+ } else if ( tagName == QString("ClassName") ) {
+ yyClassName = val;
+ } else if ( tagName == QString("DataHeader") ) {
+ dataHeader = val;
+ } else if ( tagName == QString("DataSource") ) {
+ dataSource = val;
+ } else if ( tagName == QString("DataName") ) {
+ dataName = val;
+ } else if ( tagName == QString("WindowBaseClass") ) {
+ if ( val == QString("Custom") )
+ isCustom = TRUE;
+ else
+ windowBaseClass = val;
+ } else if ( tagName == QString("IsModal") ) {
+ } else if ( tagName == QString("CustomBase") ) {
+ windowBaseClass = val;
+ } else if ( tagName == QString("CustomBaseHeader") ) {
+ customBaseHeader = val;
+ } else if ( tagName == QString("WindowCaption") ) {
+ windowCaption = val;
+ }
+ n = n.nextSibling();
+ }
+
+ emitSimpleValue( QString("class"), yyClassName );
+ emitOpeningWidget( windowBaseClass );
+
+ if ( windowCaption.isEmpty() )
+ windowCaption = yyClassName;
+ emitProperty( QString("name"), yyClassName.latin1() );
+ emitProperty( QString("caption"), windowCaption );
+
+ if ( isCustom )
+ yyCustomWidgets.insert( windowBaseClass, customBaseHeader );
+}
+
+bool Dlg2Ui::needsQLayoutWidget( const QDomElement& e )
+{
+ QRegExp widgetExists( QString("WidgetLayout|Layout_Widget") );
+
+ // we should also check that the widget is not a QHBox, QVBox, or QGrid
+ QString grandpa = e.parentNode().parentNode().toElement().tagName();
+ return !widgetExists.exactMatch( grandpa );
+}
+
+void Dlg2Ui::matchBoxLayout( const QDomElement& boxLayout )
+{
+ QString directionStr;
+ QString prevBoxKind = yyBoxKind;
+ int border = 5;
+ int autoBorder = 5;
+ QString name;
+ bool needsWidget = needsQLayoutWidget( boxLayout );
+ bool opened = FALSE;
+
+ QDomNode n = boxLayout.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+
+ if ( tagName == QString("Children") ) {
+ if ( !opened ) {
+ emitOpeningLayout( needsWidget, yyBoxKind, name, border,
+ autoBorder );
+ if ( !directionStr.isEmpty() )
+ emitProperty( QString("direction"), directionStr,
+ QString("enum") );
+ opened = TRUE;
+ }
+ matchLayout( n.toElement() );
+ } else {
+ QString val = getTextValue( n );
+
+ if ( tagName == QString("Direction") ) {
+ if ( val == QString("LeftToRight") ) {
+ yyBoxKind = QString( "hbox" );
+ } else if ( val == QString("RightToLeft") ) {
+ directionStr = val;
+ yyBoxKind = QString( "hbox" );
+ } else if ( val == QString("TopToBottom") ) {
+ yyBoxKind = QString( "vbox" );
+ } else if ( val == QString("BottomToTop") ) {
+ directionStr = val;
+ yyBoxKind = QString( "vbox" );
+ } else {
+ syntaxError();
+ }
+ } else if ( tagName == QString("Border") ) {
+ border = val.toInt();
+ } else if ( tagName == QString("AutoBorder") ) {
+ autoBorder = val.toInt();
+ } else if ( tagName == QString("Name") ) {
+ name = val;
+ }
+ }
+
+ n = n.nextSibling();
+ }
+ if ( opened ) {
+ emitClosingLayout( needsWidget, yyBoxKind );
+ yyBoxKind = prevBoxKind;
+ }
+}
+
+void Dlg2Ui::matchBoxSpacing( const QDomElement& boxSpacing )
+{
+ int spacing = 7;
+
+ QDomNode n = boxSpacing.firstChild();
+ while ( !n.isNull() ) {
+ QString val = getTextValue( n );
+
+ if ( n.toElement().tagName() == QString("Spacing") )
+ spacing = val.toInt();
+ n = n.nextSibling();
+ }
+ emitSpacer( spacing, 0 );
+}
+
+void Dlg2Ui::matchBoxStretch( const QDomElement& boxStretch )
+{
+ int stretch = 1;
+
+ QDomNode n = boxStretch.firstChild();
+ while ( !n.isNull() ) {
+ QString val = getTextValue( n );
+
+ if ( n.toElement().tagName() == QString("Stretch") )
+ stretch = val.toInt();
+ n = n.nextSibling();
+ }
+ emitSpacer( 0, stretch );
+}
+
+void Dlg2Ui::matchGridLayout( const QDomElement& gridLayout )
+{
+ int oldGridRow = yyGridRow;
+ int oldGridColumn = yyGridColumn;
+ int border = 5;
+ int autoBorder = 5;
+ QString name;
+ QString menu;
+ bool needsWidget = needsQLayoutWidget( gridLayout );
+ bool opened = FALSE;
+
+ QDomNode n = gridLayout.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+
+ if ( tagName == QString("Children") ) {
+ if ( !opened ) {
+ emitOpeningLayout( needsWidget, QString("grid"), name, border,
+ autoBorder );
+ yyGridRow = -1;
+ yyGridColumn = -1;
+ opened = TRUE;
+ }
+ matchLayout( n.toElement() );
+ } else {
+ if ( tagName == QString("Border") ) {
+ border = getTextValue( n ).toInt();
+ } else if ( tagName == QString("AutoBorder") ) {
+ autoBorder = getTextValue( n ).toInt();
+ } else if ( tagName == QString("Name") ) {
+ name = getTextValue( n );
+ } else if ( tagName == QString("Menu") ) {
+ menu = getTextValue( n );
+ }
+ }
+ n = n.nextSibling();
+ }
+ if ( opened )
+ emitClosingLayout( needsWidget, QString("grid") );
+ yyGridRow = oldGridRow;
+ yyGridColumn = oldGridColumn;
+}
+
+void Dlg2Ui::matchGridRow( const QDomElement& gridRow )
+{
+ yyGridRow++;
+
+ QDomNode n = gridRow.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+
+ if ( tagName == QString("Children") ) {
+ yyGridColumn = 0;
+ matchLayout( n.toElement() );
+ }
+ n = n.nextSibling();
+ }
+}
+
+void Dlg2Ui::matchGridSpacer( const QDomElement& gridSpacer )
+{
+ if ( !gridSpacer.firstChild().isNull() )
+ syntaxError();
+}
+
+void Dlg2Ui::matchLayoutWidget( const QDomElement& layoutWidget )
+{
+ QDomElement children;
+ QString widget;
+
+ QDomNode n = layoutWidget.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+
+ if ( tagName == QString("Children") )
+ children = n.toElement();
+ else if ( tagName == QString("Widget") )
+ widget = getTextValue( n );
+ n = n.nextSibling();
+ }
+
+ if ( !widget.isEmpty() ) {
+ QMap<QString, QDomElement>::Iterator w = yyWidgetMap.find( widget );
+ if ( w == yyWidgetMap.end() ) {
+ syntaxError();
+ } else {
+ QString className = widgetClassName( *w );
+ if ( className == QString("QHBox") ||
+ className == QString("QVBox") ) {
+ bool needsWidget = needsQLayoutWidget( layoutWidget );
+
+ QString prevBoxKind = yyBoxKind;
+ yyBoxKind = className.mid( 1 ).lower();
+
+ int spacing = getValue( (*w).childNodes(), QString("Spacing"),
+ QString("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 == QString("QGrid") ) {
+ bool needsWidget = needsQLayoutWidget( layoutWidget );
+ int n = 0;
+
+ QString direction = getValue( (*w).childNodes(),
+ QString("Direction") ).toString();
+ int rowsCols = getValue( (*w).childNodes(), QString("RowCols"),
+ QString("integer") ).toInt();
+ if ( rowsCols == 0 )
+ rowsCols = getValue( (*w).childNodes(),
+ QString("RowsCols"),
+ QString("integer") ).toInt();
+ if ( rowsCols < 1 )
+ rowsCols = 5;
+ int spacing = getValue( (*w).childNodes(), QString("Spacing"),
+ QString("integer") ).toInt();
+ if ( spacing < 1 )
+ spacing = 5;
+
+ emitOpeningLayout( needsWidget, QString("grid"), widget, 0,
+ spacing );
+
+ QDomNode child = children.firstChild();
+ while ( !child.isNull() ) {
+ if ( direction == QString("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, QString("grid") );
+ } else {
+ emitOpeningWidget( widgetClassName(*w) );
+ emitWidgetBody( *w, TRUE );
+ if ( !children.isNull() )
+ matchLayout( children );
+ emitClosing( QString("widget") );
+ }
+ yyWidgetMap.remove( w );
+ }
+ }
+}
+
+void Dlg2Ui::matchBox( const QDomElement& box )
+{
+ /*
+ What is this jump table doing in here?
+ */
+ static const struct {
+ const char *tagName;
+ void (Dlg2Ui::*matchFunc)( const QDomElement& );
+ } 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 ( QString(jumpTable[i].tagName) == box.tagName() ) {
+ (this->*jumpTable[i].matchFunc)( box );
+ break;
+ }
+ i++;
+ }
+ if ( jumpTable[i].tagName == 0 )
+ syntaxError();
+}
+
+void Dlg2Ui::matchLayout( const QDomElement& layout )
+{
+ int column = yyGridColumn;
+
+ QDomNode n = layout.firstChild();
+ while ( !n.isNull() ) {
+ if ( column != -1 )
+ yyGridColumn = column++;
+ matchBox( n.toElement() );
+ n = n.nextSibling();
+ }
+}
+
+void Dlg2Ui::matchWidgetLayoutCommon( const QDomElement& widgetLayoutCommon )
+{
+ QDomNodeList 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
+ QPoint initialPos = getValue( children, QString("InitialPos"),
+ QString("qpoint") ).toPoint();
+ QSize size = getValue( children, QString("Size"), QString("qsize") )
+ .toSize();
+#endif
+ QSize minSize = getValue( children, QString("MinSize"), QString("qsize") )
+ .toSize();
+ QSize maxSize = getValue( children, QString("MaxSize"), QString("qsize") )
+ .toSize();
+
+#if 1
+ if ( initialPos == QPoint(-1, -1) )
+ initialPos = QPoint( 0, 0 );
+
+ emitProperty( QString("geometry"), QRect(initialPos, size) );
+#endif
+ if ( minSize != QSize(-1, -1) )
+ emitProperty( QString("minimumSize"), minSize );
+ if ( maxSize != QSize(32767, 32767) )
+ emitProperty( QString("maximumSize"), maxSize );
+}
+
+void Dlg2Ui::matchWidget( const QDomElement& widget )
+{
+ QString name;
+
+ QDomNode n = widget;
+ while ( !n.isNull() ) {
+ if ( isWidgetType(n.toElement()) ) {
+ n = n.firstChild();
+ } else {
+ if ( n.toElement().tagName() == QString("Name") ) {
+ name = getTextValue( n );
+ break;
+ }
+ n = n.nextSibling();
+ }
+ }
+ if ( name.isEmpty() )
+ name = QString( "Widget%1" ).arg( uniqueWidget++ );
+
+ if ( yyWidgetMap.contains(name) )
+ syntaxError();
+ yyWidgetMap.insert( name, widget );
+}
+
+void Dlg2Ui::matchWidgets( const QDomElement& widgets )
+{
+ QDomNode n = widgets.firstChild();
+ while ( !n.isNull() ) {
+ matchWidget( n.toElement() );
+ n = n.nextSibling();
+ }
+}
+
+void Dlg2Ui::matchTabOrder( const QDomElement& tabOrder )
+{
+ QDomNode n = tabOrder.firstChild();
+ while ( !n.isNull() ) {
+ if ( n.toElement().tagName() == QString("Widget") )
+ yyTabStops.append( getTextValue(n.toElement()) );
+ n = n.nextSibling();
+ }
+}
+
+void Dlg2Ui::matchWidgetLayout( const QDomElement& widgetLayout )
+{
+ if ( !checkTagName(widgetLayout, QString("WidgetLayout")) )
+ return;
+
+ QDomNode n = widgetLayout.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+
+ if ( tagName == QString("WidgetLayoutCommon") ) {
+ matchWidgetLayoutCommon( n.toElement() );
+ } else if ( tagName == QString("Widgets") ) {
+ matchWidgets( n.toElement() );
+ } else if ( tagName == QString("TabOrder") ) {
+ matchTabOrder( n.toElement() );
+ } else if ( tagName == QString("Layout") ) {
+ matchLayout( n.toElement() );
+ }
+ n = n.nextSibling();
+ }
+}
+
+void Dlg2Ui::matchDialog( const QDomElement& dialog )
+{
+ if ( !checkTagName(dialog, QString("Dialog")) )
+ return;
+
+ QDomNodeList nodes = dialog.childNodes();
+ if ( nodes.count() == 2 ) {
+ matchDialogCommon( nodes.item(0).toElement() );
+ matchWidgetLayout( nodes.item(1).toElement() );
+ flushWidgets();
+ emitClosing( QString("widget") );
+
+ if ( !yyCustomWidgets.isEmpty() ) {
+ emitOpening( QString("customwidgets") );
+
+ QMap<QString, QString>::Iterator w = yyCustomWidgets.begin();
+ while ( w != yyCustomWidgets.end() ) {
+ emitOpening( QString("customwidget") );
+ emitSimpleValue( QString("class"), w.key() );
+ if ( !(*w).isEmpty() )
+ emitSimpleValue( QString("header"), *w,
+ attribute(QString("location"),
+ QString("local")) );
+ emitClosing( QString("customwidget") );
+ ++w;
+ }
+ emitClosing( QString("customwidgets") );
+ }
+
+ if ( yyConnections.count() + yySlots.count() > 0 ) {
+ emitOpening( QString("connections") );
+
+ QValueList<DlgConnection>::Iterator c = yyConnections.begin();
+ while ( c != yyConnections.end() ) {
+ emitOpening( QString("connection") );
+ emitSimpleValue( QString("sender"), alias((*c).sender) );
+ emitSimpleValue( QString("signal"), (*c).signal );
+ emitSimpleValue( QString("receiver"), yyClassName );
+ emitSimpleValue( QString("slot"), (*c).slot );
+ emitClosing( QString("connection") );
+ ++c;
+ }
+
+ QMap<QString, QString>::Iterator s = yySlots.begin();
+ while ( s != yySlots.end() ) {
+ AttributeMap attr;
+ attr.insert( QString("access"), *s );
+ attr.insert( QString("language"), QString("C++") );
+ attr.insert( QString("returntype"), QString("void") );
+ emitSimpleValue( QString("slot"), s.key(), attr );
+ ++s;
+ }
+ emitClosing( QString("connections") );
+ }
+
+ if ( !yyTabStops.isEmpty() ) {
+ emitOpening( QString("tabstops") );
+ QStringList::ConstIterator t = yyTabStops.begin();
+ while ( t != yyTabStops.end() ) {
+ emitSimpleValue( QString("tabstop"), alias(*t) );
+ ++t;
+ }
+ emitClosing( QString("tabstops") );
+ }
+ }
+}
+
+QStringList Dlg2Ui::convertQtArchitectDlgFile( const QString& 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( QString(widgetTypes[i]), 0 );
+ i++;
+ }
+
+ i = 0;
+ while ( propertyDefs[i].widgetName != 0 ) {
+ yyPropertyMap[QString(propertyDefs[i].widgetName)]
+ .insert( QString(propertyDefs[i].architectName), i );
+ i++;
+ }
+
+ QDomDocument doc( QString("QtArch") );
+ QFile f( fileName );
+ if ( !f.open(IO_ReadOnly) ) {
+ return QStringList();
+ }
+ if ( !doc.setContent(&f) ) {
+ QString firstLine;
+ f.at( 0 );
+ f.readLine( firstLine, 128 );
+ firstLine = firstLine.stripWhiteSpace();
+ if ( firstLine.startsWith(QString("DlgEdit:v1")) ) {
+ error( QString("This file is a Qt Architect 1.x file. Qt Designer"
+ " can only read XML dialog files, as generated by Qt"
+ " Architect 2.1 or above."
+ "<p>To convert this file to the right format,"
+ " first install Qt 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 Qt"
+ " Architect and save it. The file should now be in"
+ " XML format and loadable in Qt Designer.") );
+ } else if ( firstLine.startsWith(QString("DlgEdit::v2")) ) {
+ error( QString("This file is a Qt Architect 2.0 file. Qt Designer"
+ " can only read XML dialog files, as generated by Qt"
+ " Architect 2.1 or above."
+ "<p>To convert this file to the right format,"
+ " first install Qt Architect 2.1 (available at"
+ " <tt>http://qtarch.sourceforge.net/</tt>). Load the"
+ " 2.0 file in Qt Architect and save it. The file"
+ " should now be in XML format and loadable in Qt"
+ " Designer.") );
+ } else {
+ error( QString("The file you gave me is not an XML file, as far as"
+ " I can tell.") );
+ }
+
+ f.close();
+ return QStringList();
+ }
+ f.close();
+
+ QDomElement root = doc.documentElement();
+ if ( root.tagName() != QString("QtArch") ||
+ root.attributeNode("type").value() != QString("Dialog") ) {
+ error( QString("The file you gave me is not a Qt Architect dialog"
+ " file.") );
+ return QStringList();
+ }
+
+ emitHeader();
+
+ QDomNode n = root.firstChild();
+ while ( !n.isNull() ) {
+ // there should be only one
+ matchDialog( n.toElement() );
+ n = n.nextSibling();
+ }
+
+ emitFooter();
+
+ QFile outf;
+ QString outFileName = yyClassName + QString( ".ui" );
+
+ outf.setName( outFileName );
+ if ( !outf.open(IO_WriteOnly) ) {
+ qWarning( "dlg2ui: Could not open output file '%s'",
+ outFileName.latin1() );
+ return QStringList();
+ }
+
+ QTextStream out;
+ out.setEncoding( QTextStream::Latin1 );
+ out.setDevice( &outf );
+ out << yyOut;
+ outf.close();
+
+ return QStringList( outFileName );
+}
diff --git a/tools/designer/plugins/dlg/dlg2ui.h b/tools/designer/plugins/dlg/dlg2ui.h
new file mode 100644
index 0000000..9fb206a
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QMap<QString, QString> AttributeMap;
+
+struct DlgConnection
+{
+ QString sender;
+ QString signal;
+ QString slot;
+
+#if defined(Q_FULL_TEMPLATE_INSTANTIATION)
+ bool operator==( const DlgConnection& ) const {
+ return sender == sender && signal == signal && slot == slot;
+ }
+#endif
+};
+
+class Dlg2Ui
+{
+public:
+ QStringList convertQtArchitectDlgFile( const QString& fileName );
+
+private:
+ QString alias( const QString& name ) const;
+ QString opening( const QString& tag,
+ const AttributeMap& attr = AttributeMap() );
+ QString closing( const QString& tag );
+ void error( const QString& message );
+ void syntaxError();
+ QString getTextValue( const QDomNode& node );
+ QVariant getValue( const QDomNodeList& children, const QString& tagName,
+ const QString& type = "qstring" );
+ void emitHeader();
+ void emitFooter();
+ void emitSimpleValue( const QString& tag, const QString& value,
+ const AttributeMap& attr = AttributeMap() );
+ void emitOpening( const QString& tag,
+ const AttributeMap& attr = AttributeMap() );
+ void emitClosing( const QString& tag );
+ void emitOpeningWidget( const QString& className );
+ QString widgetClassName( const QDomElement& e );
+ void emitColor( const QColor& color );
+ void emitColorGroup( const QString& name, const QColorGroup& group );
+ void emitVariant( const QVariant& val,
+ const QString& stringType = "string" );
+ void emitProperty( const QString& prop, const QVariant& val,
+ const QString& stringType = "string" );
+ void emitAttribute( const QString& attr, const QVariant& val,
+ const QString& stringType = "string" );
+ void emitOpeningLayout( bool needsWidget, const QString& layoutKind,
+ const QString& name, int border, int autoBorder );
+ void flushWidgets();
+ void emitClosingLayout( bool needsWidget, const QString& layoutKind );
+ bool isWidgetType( const QDomElement& e );
+ void emitSpacer( int spacing, int stretch );
+ QString filteredFlags( const QString& flags, const QRegExp& filter );
+ void emitFrameStyleProperty( int style );
+ void emitWidgetBody( const QDomElement& e, bool layouted );
+ bool checkTagName( const QDomElement& e, const QString& tagName );
+ QString normalizeType( const QString& type );
+ QVariant getValue( const QDomElement& e, const QString& tagName,
+ const QString& type = "qstring" );
+ void matchDialogCommon( const QDomElement& dialogCommon );
+ bool needsQLayoutWidget( const QDomElement& e );
+ void matchBoxLayout( const QDomElement& boxLayout );
+ void matchBoxSpacing( const QDomElement& boxSpacing );
+ void matchBoxStretch( const QDomElement& boxStretch );
+ void matchGridLayout( const QDomElement& gridLayout );
+ void matchGridRow( const QDomElement& gridRow );
+ void matchGridSpacer( const QDomElement& gridSpacer );
+ void matchLayoutWidget( const QDomElement& layoutWidget );
+ void matchBox( const QDomElement& box );
+ void matchLayout( const QDomElement& layout );
+ void matchWidgetLayoutCommon( const QDomElement& widgetLayoutCommon );
+ void matchWidget( const QDomElement& widget );
+ void matchWidgets( const QDomElement& widgets );
+ void matchTabOrder( const QDomElement& tabOrder );
+ void matchWidgetLayout( const QDomElement& widgetLayout );
+ void matchDialog( const QDomElement& dialog );
+
+ QString yyOut;
+ QString yyIndentStr;
+ QString yyFileName;
+ QString yyClassName;
+ QMap<QString, int> yyWidgetTypeSet;
+ QMap<QString, QMap<QString, int> > yyPropertyMap;
+ QMap<QString, QDomElement> yyWidgetMap;
+ QMap<QString, QString> yyCustomWidgets;
+ QValueList<DlgConnection> yyConnections;
+ QMap<QString, QString> yySlots;
+ QMap<QString, QString> yyAliasMap;
+ QStringList yyTabStops;
+ QString 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 0000000..b698bad
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QLibraryInterface
+{
+public:
+ DlgFilter();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface **iface );
+ Q_REFCOUNT;
+
+ QStringList featureList() const;
+ QStringList import( const QString& filter, const QString& filename );
+
+ bool init();
+ void cleanup();
+ bool canUnload() const;
+};
+
+DlgFilter::DlgFilter()
+{
+}
+
+QRESULT DlgFilter::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)(ImportFilterInterface*)this;
+ else if ( uuid == IID_QFeatureList )
+ *iface = (QFeatureListInterface*)this;
+ else if ( uuid == IID_ImportFilter )
+ *iface = (ImportFilterInterface*)this;
+ else if ( uuid == IID_QLibrary )
+ *iface = (QLibraryInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+QStringList DlgFilter::featureList() const
+{
+ QStringList list;
+ list << "Qt Architect Dialog Files (*.dlg)" ;
+ return list;
+}
+
+QStringList DlgFilter::import( const QString &, const QString& filename )
+{
+ Dlg2Ui d;
+ return d.convertQtArchitectDlgFile( 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 0000000..c1be0c5
--- /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 0000000..39ff5e8
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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", "QDialog" },
+ { "GnomeApp", "QMainWindow" },
+ { "GnomeCanvas", "QLabel" },
+ { "GnomeColorPicker", "QComboBox" },
+ { "GnomeDateEdit", "QDateTimeEdit" },
+ { "GnomeDialog", "QDialog" },
+ { "GnomeFontPicker", "QComboBox" },
+ { "GnomeIconSelection", "QIconView" },
+ { "GnomePixmap", "QLabel" },
+ { "GnomePropertyBox", "QDialog" },
+ { "GtkAccelLabel", "QLabel" },
+ { "GtkAspectFrame", "QFrame" },
+ { "GtkButton", "QPushButton" },
+ { "GtkCList", "QListView" },
+ { "GtkCTree", "QListView" },
+ { "GtkCheckButton", "QCheckBox" },
+ { "GtkCombo", "QComboBox" },
+ { "GtkDial", "QDial" },
+ { "GtkDialog", "QDialog" },
+ { "GtkEntry", "QLineEdit" },
+ { "GtkFixed", "QLayoutWidget" },
+ { "GtkFrame", "QFrame" },
+ { "GtkHPaned", "QSplitter" },
+ { "GtkHScale", "QSlider" },
+ { "GtkHScrollbar", "QScrollBar" },
+ { "GtkHSeparator", "Line" },
+ { "GtkHandleBox", "QFrame" },
+ { "GtkImage", "QLabel" },
+ { "GtkLabel", "QLabel" },
+ { "GtkList", "QListBox" },
+ { "GtkNotebook", "QTabWidget" },
+ { "GtkOptionMenu", "QComboBox" },
+ { "GtkPixmap", "QLabel" },
+ { "GtkPreview", "QLabel" },
+ { "GtkProgressBar", "QProgressBar" },
+ { "GtkRadioButton", "QRadioButton" },
+ { "GtkSpinButton", "QSpinBox" },
+ { "GtkStatusbar", "QStatusBar" },
+ { "GtkText", "QTextEdit" },
+ { "GtkToggleButton", "QPushButton" },
+ { "GtkTree", "QListView" },
+ { "GtkVPaned", "QSplitter" },
+ { "GtkVScale", "QSlider" },
+ { "GtkVScrollbar", "QScrollBar" },
+ { "GtkVSeparator", "Line" },
+ { "Placeholder", "QLabel" },
+ { 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", Qt::Key_BackSpace },
+ { "Delete", Qt::Key_Delete },
+ { "Down", Qt::Key_Down },
+ { "End", Qt::Key_End },
+ { "Escape", Qt::Key_Escape },
+ { "F1", Qt::Key_F1 },
+ { "F10", Qt::Key_F10 },
+ { "F11", Qt::Key_F11 },
+ { "F12", Qt::Key_F12 },
+ { "F2", Qt::Key_F2 },
+ { "F3", Qt::Key_F3 },
+ { "F4", Qt::Key_F4 },
+ { "F5", Qt::Key_F5 },
+ { "F6", Qt::Key_F6 },
+ { "F7", Qt::Key_F7 },
+ { "F8", Qt::Key_F8 },
+ { "F9", Qt::Key_F9 },
+ { "Home", Qt::Key_Home },
+ { "Insert", Qt::Key_Insert },
+ { "KP_Enter", Qt::Key_Enter },
+ { "Left", Qt::Key_Left },
+ { "Page_Down", Qt::Key_PageDown },
+ { "Page_Up", Qt::Key_PageUp },
+ { "Return", Qt::Key_Return },
+ { "Right", Qt::Key_Right },
+ { "Tab", Qt::Key_Tab },
+ { "Up", Qt::Key_Up },
+ { "space", Qt::Key_Space },
+ { 0, 0 }
+};
+
+static QString nonMenuText( const QString& menuText )
+{
+ QString t;
+ int len = (int) menuText.length();
+ if ( menuText.endsWith(QString("...")) )
+ len -= 3;
+ for ( int i = 0; i < len; i++ ) {
+ if ( menuText[i] != QChar('&') )
+ t += menuText[i];
+ }
+ return t;
+}
+
+/*
+ Some GTK dialog use hyphens in variable names. Let's take no chance.
+*/
+static QString fixedName( const QString& name )
+{
+ const char *latin1 = name.latin1();
+ QString fixed;
+
+ int i = 0;
+ while ( latin1 != 0 && latin1[i] != '\0' ) {
+ if ( isalnum(latin1[i]) )
+ fixed += name[i];
+ else
+ fixed += QChar( '_' );
+ i++;
+ }
+ return fixed;
+}
+
+/*
+ Returns an hexadecimal rendering of a block of memory.
+*/
+static QString hexed( const char *data, int length )
+{
+ QString t;
+ for ( int i = 0; i < length; i++ ) {
+ QString x;
+ x.sprintf( "%.2x", (uchar) data[i] );
+ t += x;
+ }
+ return t;
+}
+
+static bool isTrue( const QString& val )
+{
+ return val.lower() == QString( "true" );
+}
+
+static AttributeMap attribute( const QString& name, const QString& val )
+{
+ AttributeMap attr;
+ attr.insert( name, val );
+ return attr;
+}
+
+static QString entitize( const QString& str )
+{
+ QString t = str;
+ t.replace( '&', QString("&amp;") );
+ t.replace( '>', QString("&gt;") );
+ t.replace( '<', QString("&lt;") );
+ t.replace( '"', QString("&quot;") );
+ t.replace( '\'', QString("&apos;") );
+ return t;
+}
+
+Glade2Ui::Glade2Ui()
+{
+ int i = 0;
+ while ( classNames[i].gtkName != 0 ) {
+ yyClassNameMap.insert( QString(classNames[i].gtkName),
+ QString(classNames[i].qtName) );
+ i++;
+ }
+
+ i = 0;
+ while ( stockMenuItems[i].name != 0 ) {
+ yyStockMap.insert( QString(stockMenuItems[i].name),
+ QString(stockMenuItems[i].menuText) );
+ i++;
+ }
+
+ i = 0;
+ while ( keys[i].gtkName != 0 ) {
+ yyKeyMap.insert( QString(keys[i].gtkName), keys[i].qtValue );
+ i++;
+ }
+}
+
+QString Glade2Ui::imageName( const QString& fileName )
+{
+ return *yyImages.insert( fileName, QString("image%1").arg(yyImages.count()),
+ FALSE );
+}
+
+QString Glade2Ui::opening( const QString& tag, const AttributeMap& attr )
+{
+ QString t = QChar( '<' ) + tag;
+ AttributeMap::ConstIterator a = attr.begin();
+ while ( a != attr.end() ) {
+ t += QChar( ' ' ) + a.key() + QString( "=\"" ) + entitize( *a ) +
+ QChar( '"' );
+ ++a;
+ }
+ t += QChar( '>' );
+ return t;
+}
+
+QString Glade2Ui::closing( const QString& tag )
+{
+ return opening( QChar('/') + tag );
+}
+
+QString Glade2Ui::atom( const QString& tag, const AttributeMap& attr )
+{
+ QString t = opening( tag, attr );
+ t.insert( t.length() - 1, QChar('/') );
+ return t;
+}
+
+void Glade2Ui::error( const QString& message )
+{
+ if ( numErrors++ == 0 )
+ QMessageBox::warning( 0, yyFileName, message );
+}
+
+void Glade2Ui::syntaxError()
+{
+ error( QString("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.") );
+}
+
+QString Glade2Ui::getTextValue( const QDomNode& node )
+{
+ if ( node.childNodes().count() > 1 ) {
+ syntaxError();
+ return QString::null;
+ }
+
+ if ( node.childNodes().count() == 0 )
+ return QString::null;
+
+ QDomText t = node.firstChild().toText();
+ if ( t.isNull() ) {
+ syntaxError();
+ return QString::null;
+ }
+ return t.data().stripWhiteSpace();
+}
+
+void Glade2Ui::emitHeader()
+{
+ yyOut += QString( "<!DOCTYPE UI><UI version=\"3.0\" stdsetdef=\"1\">\n" );
+}
+
+void Glade2Ui::emitFooter()
+{
+ yyOut += QString( "</UI>\n" );
+}
+
+void Glade2Ui::emitSimpleValue( const QString& tag, const QString& value,
+ const AttributeMap& attr )
+{
+ yyOut += yyIndentStr + opening( tag, attr ) + entitize( value ) +
+ closing( tag ) + QChar( '\n' );
+}
+
+void Glade2Ui::emitOpening( const QString& tag, const AttributeMap& attr )
+{
+ yyOut += yyIndentStr + opening( tag, attr ) + QChar( '\n' );
+ yyIndentStr += QString( " " );
+}
+
+void Glade2Ui::emitClosing( const QString& tag )
+{
+ yyIndentStr.truncate( yyIndentStr.length() - 4 );
+ yyOut += yyIndentStr + closing( tag ) + QChar( '\n' );
+}
+
+void Glade2Ui::emitAtom( const QString& tag, const AttributeMap& attr )
+{
+ yyOut += yyIndentStr + atom( tag, attr ) + QChar( '\n' );
+}
+
+void Glade2Ui::emitVariant( const QVariant& val, const QString& stringType )
+{
+ if ( val.isValid() ) {
+ switch ( val.type() ) {
+ case QVariant::String:
+ emitSimpleValue( stringType, val.toString() );
+ break;
+ case QVariant::CString:
+ emitSimpleValue( QString("cstring"), val.toString() );
+ break;
+ case QVariant::Bool:
+ emitSimpleValue( QString("bool"),
+ QString(val.toBool() ? "true" : "false") );
+ break;
+ case QVariant::Int:
+ case QVariant::UInt:
+ emitSimpleValue( QString("number"), val.toString() );
+ break;
+ case QVariant::Rect:
+ emitOpening( QString("rect") );
+ emitSimpleValue( QString("x"), QString::number(val.toRect().x()) );
+ emitSimpleValue( QString("y"), QString::number(val.toRect().y()) );
+ emitSimpleValue( QString("width"),
+ QString::number(val.toRect().width()) );
+ emitSimpleValue( QString("height"),
+ QString::number(val.toRect().height()) );
+ emitClosing( QString("rect") );
+ break;
+ case QVariant::Size:
+ emitOpening( QString("size") );
+ emitSimpleValue( QString("width"),
+ QString::number(val.toSize().width()) );
+ emitSimpleValue( QString("height"),
+ QString::number(val.toSize().height()) );
+ emitClosing( QString("size") );
+ break;
+ case QVariant::SizePolicy:
+ emitOpening( QString("sizepolicy") );
+ emitSimpleValue( QString("hsizetype"),
+ QString::number((int) val.toSizePolicy()
+ .horData()) );
+ emitSimpleValue( QString("vsizetype"),
+ QString::number((int) val.toSizePolicy()
+ .verData()) );
+ emitClosing( QString("sizepolicy") );
+ break;
+ default:
+ emitSimpleValue( QString("fnord"), QString::null );
+ }
+ }
+}
+
+void Glade2Ui::emitProperty( const QString& prop, const QVariant& val,
+ const QString& stringType )
+{
+ emitOpening( QString("property"), attribute(QString("name"), prop) );
+ emitVariant( val, stringType );
+ emitClosing( QString("property") );
+}
+
+void Glade2Ui::emitFontProperty( const QString& prop, int pointSize, bool bold )
+{
+ emitOpening( QString("property"), attribute(QString("name"), prop) );
+ emitOpening( QString("font") );
+ emitSimpleValue( QString("pointsize"), QString::number(pointSize) );
+ if ( bold )
+ emitSimpleValue( QString("bold"), QString("1") );
+ emitClosing( QString("font") );
+ emitClosing( QString("property") );
+}
+
+void Glade2Ui::emitAttribute( const QString& prop, const QVariant& val,
+ const QString& stringType )
+{
+ emitOpening( QString("attribute"), attribute(QString("name"), prop) );
+ emitVariant( val, stringType );
+ emitClosing( QString("attribute") );
+}
+
+static QString accelerate( const QString& gtkLabel )
+{
+ QString qtLabel = gtkLabel;
+ qtLabel.replace( '&', QString("&&") );
+ // close but not quite right
+ qtLabel.replace( QChar('_'), QChar('&') );
+ return qtLabel;
+}
+
+static QString decelerate( const QString& gtkLabel )
+{
+ QString qtLabel = gtkLabel;
+ // ditto
+ qtLabel.replace( '_', QString::null );
+ return qtLabel;
+}
+
+/*
+ Converting a GTK widget to a corresponding Qt widget is sometimes
+ hard. For example, a GtkScrolledWindow should sometimes be converted
+ into a QTextView, a QTextEdit, a QListView or whatever. What we do
+ is pretty hackish, but it mostly works.
+*/
+QString Glade2Ui::gtk2qtClass( const QString& gtkClass,
+ const QValueList<QDomElement>& childWidgets )
+{
+ QRegExp gnomeXEntry( QString("Gnome(File|Number|Pixmap)?Entry") );
+
+ QString qtClass;
+
+ if ( gtkClass == QString("GtkScrolledWindow") ) {
+ if ( childWidgets.count() == 1 ) {
+ QString g;
+ bool editable = FALSE;
+ bool showTitles = TRUE;
+
+ QDomNode n = childWidgets.first().firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("class") ) {
+ g = getTextValue( n );
+ } else if ( tagName == QString("editable") ) {
+ editable = isTrue( getTextValue(n) );
+ } else if ( tagName.startsWith(QString("show_tit")) ) {
+ showTitles = isTrue( getTextValue(n) );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( g == QString("GnomeCanvas") ||
+ g == QString("GtkDrawingArea") ) {
+ qtClass = QString( "QLabel" );
+ } else if ( g == QString("GnomeIconList") ) {
+ qtClass = QString( "QIconView" );
+ } else if ( g == QString("GtkCList") ) {
+ if ( showTitles )
+ qtClass = QString( "QListView" );
+ else
+ qtClass = QString( "QListBox" );
+ } else if ( g == QString("GtkCTree") ) {
+ qtClass = QString( "QListView" );
+ } else if ( g == QString("GtkList") ) {
+ qtClass = QString( "QListBox" );
+ } else if ( g == QString("GtkText") ) {
+ if ( editable )
+ qtClass = QString( "QTextEdit" );
+ else
+ qtClass = QString( "QTextView" );
+ } else if ( g == QString("GtkTree") ) {
+ qtClass = QString( "QListView" );
+ }
+ // else too bad (qtClass is empty)
+ }
+ } else if ( gtkClass == QString("GtkWindow") ) {
+ qtClass = QString( "QDialog" );
+ if ( childWidgets.count() == 1 ) {
+ QString g;
+
+ QDomNode n = childWidgets.first().firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("class") )
+ g = getTextValue( n );
+ n = n.nextSibling();
+ }
+ if ( g == QString("GnomeDruid") )
+ qtClass = QString( "QWizard" );
+ }
+ /*
+ GnomeEntry and friends are a wrapper around a GtkEntry. We only
+ want the GtkEntry child.
+ */
+ } else if ( !gnomeXEntry.exactMatch(gtkClass) &&
+ gtkClass != QString("GtkAlignment") &&
+ gtkClass != QString("GtkEventBox") ) {
+ qtClass = yyClassNameMap[gtkClass];
+ if ( qtClass.isEmpty() )
+ qtClass = QString( "Unknown" );
+ }
+ return qtClass;
+}
+
+static QString gtk2qtScrollBarMode( const QString& scrollbarPolicy )
+{
+ if ( scrollbarPolicy.endsWith(QString("_NEVER")) ) {
+ return QString( "AlwaysOff" );
+ } else if ( scrollbarPolicy.endsWith(QString("_ALWAYS")) ) {
+ return QString( "AlwaysOn" );
+ } else {
+ return QString( "Auto" );
+ }
+}
+
+static QString gtk2qtSelectionMode( const QString& selectionMode )
+{
+ if ( selectionMode.endsWith(QString("_MULTIPLE")) )
+ return QString( "Multi" );
+ else if ( selectionMode.endsWith(QString("_EXTENDED")) )
+ return QString( "Extended" );
+ else
+ return QString( "Single" );
+}
+
+int Glade2Ui::matchAccelOnActivate( const QDomElement& accel )
+{
+ QString key;
+ QString modifiers;
+
+ QDomNode n = accel.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("key") ) {
+ key = getTextValue( n );
+ if ( !key.startsWith(QString("GDK_")) )
+ return 0;
+ } else if ( tagName == QString("modifiers") ) {
+ modifiers = getTextValue( n );
+ } else if ( tagName == QString("signal") ) {
+ if ( getTextValue(n) != QString("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(QString("_CONTROL_")) )
+ flags |= Qt::CTRL;
+ if ( modifiers.contains(QString("_SHIFT_")) )
+ flags |= Qt::SHIFT;
+ if ( modifiers.contains(QString("_MOD1_")) )
+ flags |= Qt::ALT;
+ return flags;
+}
+
+void Glade2Ui::emitGtkMenu( const QDomElement& menu )
+{
+ QRegExp gnomeuiinfoMenuXItem( QString("GNOMEUIINFO_MENU_(.+)_ITEM") );
+
+ QDomNode n = menu.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("widget") ) {
+ QString activateHandler;
+ QString gtkClass;
+ QString icon;
+ QString label;
+ QString name;
+ QString stockItem;
+ QString tooltip;
+ int qtAccel = 0;
+
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ QString childTagName = child.toElement().tagName();
+ if ( childTagName == QString("accelerator") ) {
+ qtAccel = matchAccelOnActivate( child.toElement() );
+ } else if ( childTagName == QString("class") ) {
+ gtkClass = getTextValue( child );
+ } else if ( childTagName == QString("icon") ) {
+ icon = getTextValue( child );
+ } else if ( childTagName == QString("label") ) {
+ label = getTextValue( child );
+ } else if ( childTagName == QString("name") ) {
+ name = getTextValue( child );
+ } else if ( childTagName == QString("signal") ) {
+ QString signalName;
+ QString signalHandler;
+
+ QDomNode grandchild = child.firstChild();
+ while ( !grandchild.isNull() ) {
+ QString grandchildTagName =
+ grandchild.toElement().tagName();
+ if ( grandchildTagName == QString("handler") ) {
+ signalHandler = getTextValue( grandchild );
+ } else if ( grandchildTagName == QString("name") ) {
+ signalName = getTextValue( grandchild );
+ }
+ grandchild = grandchild.nextSibling();
+ }
+ if ( signalName == QString("activate") )
+ activateHandler = signalHandler;
+ } else if ( childTagName == QString("stock_item") ) {
+ stockItem = getTextValue( child );
+ } else if ( childTagName == QString("tooltip") ) {
+ tooltip = getTextValue( child );
+ }
+ child = child.nextSibling();
+ }
+
+ if ( label.length() + stockItem.length() == 0 ) {
+ emitAtom( QString("separator") );
+ } else {
+ if ( name.isEmpty() )
+ name = QString( "action%1" ).arg( uniqueAction++ );
+ emitAtom( QString("action"), attribute(QString("name"), name) );
+
+ if ( !activateHandler.isEmpty() ) {
+ QString slot = activateHandler + QString( "()" );
+ GladeConnection c;
+ c.sender = name;
+ c.signal = QString( "activated()" );
+ c.slot = slot;
+ yyConnections.push_back( c );
+ yySlots.insert( slot, QString("public") );
+ }
+
+ QString x;
+ GladeAction a;
+
+ if ( gnomeuiinfoMenuXItem.exactMatch(stockItem) ) {
+ x = gnomeuiinfoMenuXItem.cap( 1 );
+ a.menuText = yyStockMap[x];
+ if ( x == QString("EXIT") && qtAccel == 0 )
+ qtAccel = Qt::CTRL + Qt::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 QValueList<QDomElement>& childWidgets )
+{
+ QRegExp gnomeuiinfoMenuXTree( QString("GNOMEUIINFO_MENU_(.+)_TREE") );
+
+ emitOpening( QString("menubar") );
+ emitProperty( QString("name"),
+ QString("MenuBar%1").arg(uniqueMenuBar++).latin1() );
+
+ QValueList<QDomElement>::ConstIterator c = childWidgets.begin();
+ while ( c != childWidgets.end() ) {
+ QValueList<QDomElement> grandchildWidgets;
+ QString gtkClass;
+ QString label;
+ QString name;
+ QString stockItem;
+
+ QDomNode n = (*c).firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("class") ) {
+ gtkClass = getTextValue( n );
+ } else if ( tagName == QString("label") ) {
+ label = getTextValue( n );
+ } else if ( tagName == QString("name") ) {
+ name = getTextValue( n );
+ } else if ( tagName == QString("stock_item") ) {
+ stockItem = getTextValue( n );
+ } else if ( tagName == QString("widget") ) {
+ grandchildWidgets.push_back( n.toElement() );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( gtkClass == QString("GtkMenuItem") &&
+ grandchildWidgets.count() == 1 ) {
+ QString text;
+ if ( gnomeuiinfoMenuXTree.exactMatch(stockItem) ) {
+ text = gnomeuiinfoMenuXTree.cap( 1 );
+ if ( text == QString("Files") )
+ text = QString( "Fi&les" );
+ else
+ text = QChar( '&' ) + text.left( 1 ) +
+ text.mid( 1 ).lower();
+ } else {
+ text = accelerate( label );
+ }
+
+ AttributeMap attr;
+ attr.insert( QString("name"), name );
+ attr.insert( QString("text"), text );
+
+ emitOpening( QString("item"), attr );
+ emitGtkMenu( grandchildWidgets.first() );
+ emitClosing( QString("item") );
+ }
+ ++c;
+ }
+ emitClosing( QString("menubar") );
+}
+
+void Glade2Ui::emitGtkToolbarChildWidgets(
+ const QValueList<QDomElement>& childWidgets )
+{
+ QRegExp gnomeStockPixmapX( QString("GNOME_STOCK_PIXMAP_(.+)") );
+
+ emitOpening( QString("toolbar"), attribute(QString("dock"), QString("2")) );
+ emitProperty( QString("name"),
+ QString("ToolBar%1").arg(uniqueToolBar++).latin1() );
+
+ QValueList<QDomElement>::ConstIterator c = childWidgets.begin();
+ while ( c != childWidgets.end() ) {
+ QString childName;
+ QString icon;
+ QString label;
+ QString name;
+ QString stockPixmap;
+ QString tooltip;
+
+ QDomNode n = (*c).firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("child_name") ) {
+ childName = getTextValue( n );
+ } else if ( tagName == QString("icon") ) {
+ icon = getTextValue( n );
+ } else if ( tagName == QString("label") ) {
+ label = getTextValue( n );
+ } else if ( tagName == QString("name") ) {
+ name = getTextValue( n );
+ } else if ( tagName == QString("stock_pixmap") ) {
+ stockPixmap = getTextValue( n );
+ } else if ( tagName == QString("tooltip") ) {
+ tooltip = getTextValue( n );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( childName == QString("Toolbar:button") ) {
+ QString actionName;
+ GladeAction a;
+ a.menuText = label;
+ a.text = label;
+ a.accel = 0;
+ a.iconSet = icon;
+
+ if ( gnomeStockPixmapX.exactMatch(stockPixmap) ) {
+ QString x = gnomeStockPixmapX.cap( 1 );
+ actionName = yyStockItemActions[x];
+ }
+ if ( actionName.isEmpty() ) {
+ if ( name.isEmpty() )
+ actionName = QString( "action%1" ).arg( uniqueAction++ );
+ else
+ actionName = QString( "action_%1" ).arg( name );
+ yyActions.insert( actionName, a );
+ }
+ if ( !tooltip.isEmpty() )
+ yyActions[actionName].toolTip = tooltip;
+
+ emitAtom( QString("action"), attribute(QString("name"),
+ actionName) );
+ } else {
+ emitAtom( QString("separator") );
+ }
+ ++c;
+ }
+ emitClosing( QString("toolbar") );
+}
+
+void Glade2Ui::emitPushButton( const QString& text, const QString& name )
+{
+ emitOpening( QString("widget"),
+ attribute(QString("class"), QString("QPushButton")) );
+ emitProperty( QString("name"), name.latin1() );
+ emitProperty( QString("text"), text );
+ if ( name.contains(QString("ok")) > 0 ) {
+ emitProperty( QString("default"), QVariant(TRUE, 0) );
+ } else if ( name.contains(QString("help")) > 0 ) {
+ emitProperty( QString("accel"), (int) Qt::Key_F1 );
+ }
+ emitClosing( QString("widget") );
+}
+
+void Glade2Ui::attach( AttributeMap *attr, int leftAttach, int rightAttach,
+ int topAttach, int bottomAttach )
+{
+ if ( leftAttach >= 0 ) {
+ attr->insert( QString("row"), QString::number(topAttach) );
+ attr->insert( QString("column"), QString::number(leftAttach) );
+ if ( bottomAttach - topAttach != 1 )
+ attr->insert( QString("rowspan"),
+ QString::number(bottomAttach - topAttach) );
+ if ( rightAttach - leftAttach != 1 )
+ attr->insert( QString("colspan"),
+ QString::number(rightAttach - leftAttach) );
+ }
+}
+
+void Glade2Ui::emitSpacer( const QString& orientation, int leftAttach,
+ int rightAttach, int topAttach, int bottomAttach )
+{
+ AttributeMap attr;
+ attach( &attr, leftAttach, rightAttach, topAttach, bottomAttach );
+ emitOpening( QString("spacer"), attr );
+ emitProperty( QString("name"),
+ QString("Spacer%1").arg(uniqueSpacer++).latin1() );
+ emitProperty( QString("orientation"), orientation, QString("enum") );
+ emitProperty( QString("sizeType"), QString("Expanding"),
+ QString("enum") );
+ emitClosing( QString("spacer") );
+}
+
+void Glade2Ui::emitPixmap( const QString& imageName, int leftAttach,
+ int rightAttach, int topAttach, int bottomAttach )
+{
+ emitOpeningWidget( QString("QLabel"), leftAttach, rightAttach, topAttach,
+ bottomAttach );
+ emitProperty( QString("sizePolicy"),
+ QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) );
+ emitProperty( QString("pixmap"), imageName, QString("pixmap") );
+ emitClosing( QString("widget") );
+}
+
+void Glade2Ui::emitGnomeAbout( QString copyright, QString authors,
+ QString comments )
+{
+ QString prog = yyProgramName;
+ if ( prog.isEmpty() )
+ prog = QString( "Gnomovision 1.69" );
+ if ( copyright.isEmpty() )
+ copyright = QString( "(C) 2001 Jasmin Blanchette" );
+ if ( authors.isEmpty() )
+ authors = QString( "Jasmin Blanchette <jasmin@troll.no>" );
+ if ( comments.isEmpty() )
+ comments = QString( "Gnomovision is the official GNU application." );
+
+ emitOpening( QString("hbox") );
+ emitSpacer( QString("Horizontal") );
+ emitOpeningWidget( QString("QLayoutWidget") );
+ emitOpening( QString("vbox") );
+ emitProperty( QString("spacing"), 17 );
+
+ /*
+ Emit the application name.
+ */
+ emitOpeningWidget( QString("QLabel") );
+ emitFontProperty( QString("font"), 24, TRUE );
+ emitProperty( QString("text"), prog );
+ emitProperty( QString("alignment"), QString("AlignAuto|AlignCenter"),
+ QString("set") );
+ emitClosing( QString("widget") );
+
+ /*
+ Emit the copyright notice.
+ */
+ emitOpeningWidget( QString("QLabel") );
+ emitFontProperty( QString("font"), 12, TRUE );
+ emitProperty( QString("text"), copyright );
+ emitClosing( QString("widget") );
+
+ /*
+ Emit the authors' names.
+ */
+ emitOpeningWidget( QString("QLayoutWidget") );
+ emitOpening( QString("hbox") );
+
+ emitOpeningWidget( QString("QLabel") );
+ emitFontProperty( QString("font"), 12, TRUE );
+ emitProperty( QString("text"), QString("Authors:") );
+ emitProperty( QString("alignment"), QString("AlignAuto|AlignTop"),
+ QString("set") );
+ emitClosing( QString("widget") );
+
+ emitOpeningWidget( QString("QLabel") );
+ emitFontProperty( QString("font"), 12, FALSE );
+ emitProperty( QString("text"), authors );
+ emitProperty( QString("alignment"), QString("AlignAuto|AlignTop"),
+ QString("set") );
+ emitClosing( QString("widget") );
+
+ emitSpacer( QString("Horizontal") );
+
+ emitClosing( QString("hbox") );
+ emitClosing( QString("widget") );
+
+ /*
+ Emit the comments.
+ */
+ emitOpeningWidget( QString("QLabel") );
+ emitFontProperty( QString("font"), 10, FALSE );
+ emitProperty( QString("text"), comments );
+ emitProperty( QString("alignment"), QString("AlignAuto|AlignTop"),
+ QString("set") );
+ emitClosing( QString("widget") );
+
+ /*
+ Emit the spacer and the OK button.
+ */
+ emitSpacer( QString("Vertical") );
+
+ emitOpeningWidget( QString("QLayoutWidget") );
+ emitOpening( QString("hbox") );
+ emitSpacer( QString("Horizontal") );
+
+ emitPushButton( QString("&OK"), QString("okButton") );
+
+ emitSpacer( QString("Horizontal") );
+ emitClosing( QString("hbox") );
+ emitClosing( QString("widget") );
+
+ emitClosing( QString("vbox") );
+ emitClosing( QString("widget") );
+ emitSpacer( QString("Horizontal") );
+ emitClosing( QString("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 QValueList<QDomElement>& childWidgets )
+{
+ QValueList<QDomElement>::ConstIterator c = childWidgets.begin();
+ while ( c != childWidgets.end() ) {
+ QValueList<QDomElement> grandchildWidgets;
+ QString childName;
+
+ QDomNode n = (*c).firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("child_name") ) {
+ childName = getTextValue( n );
+ } else if ( tagName == QString("widget") ) {
+ grandchildWidgets.push_back( n.toElement() );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( childName == QString("GnomeDock:contents") ) {
+ emitWidget( *c, FALSE );
+ } else {
+ emitGnomeAppChildWidgetsPass1( grandchildWidgets );
+ }
+ ++c;
+ }
+}
+
+void Glade2Ui::doPass2( const QValueList<QDomElement>& childWidgets,
+ QValueList<QDomElement> *menuBar,
+ QValueList<QValueList<QDomElement> > *toolBars )
+{
+ QValueList<QDomElement>::ConstIterator c = childWidgets.begin();
+ while ( c != childWidgets.end() ) {
+ QValueList<QDomElement> grandchildWidgets;
+ QString childName;
+ QString gtkClass;
+
+ QDomNode n = (*c).firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("child_name") ) {
+ childName = getTextValue( n );
+ } else if ( tagName == QString("class") ) {
+ gtkClass = getTextValue( n );
+ } else if ( tagName == QString("widget") ) {
+ grandchildWidgets.push_back( n.toElement() );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( gtkClass == QString("GtkMenuBar") ) {
+ *menuBar = grandchildWidgets;
+ } else if ( gtkClass == QString("GtkToolbar") ) {
+ toolBars->push_back( grandchildWidgets );
+ } else if ( childName != QString("GnomeDock:contents") ) {
+ doPass2( grandchildWidgets, menuBar, toolBars );
+ }
+ ++c;
+ }
+}
+
+void Glade2Ui::emitGnomeAppChildWidgetsPass2(
+ const QValueList<QDomElement>& childWidgets )
+{
+ QValueList<QDomElement> menuBar;
+ QValueList<QValueList<QDomElement> > toolBars;
+
+ doPass2( childWidgets, &menuBar, &toolBars );
+
+ emitGtkMenuBarChildWidgets( menuBar );
+ if ( !toolBars.isEmpty() ) {
+ emitOpening( QString("toolbars") );
+ while ( !toolBars.isEmpty() ) {
+ emitGtkToolbarChildWidgets( toolBars.first() );
+ toolBars.remove( toolBars.begin() );
+ }
+ emitClosing( QString("toolbars") );
+ }
+}
+
+void Glade2Ui::emitGtkButtonChildWidgets( QValueList<QDomElement> childWidgets )
+{
+ QValueList<QDomElement>::ConstIterator c = childWidgets.begin();
+ while ( c != childWidgets.end() ) {
+ QString label;
+
+ QDomNode n = (*c).firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("label") ) {
+ label = getTextValue( n );
+ } else if ( tagName == QString("widget") ) {
+ childWidgets.push_back( n.toElement() );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( !label.isEmpty() ) {
+ emitProperty( QString("text"), accelerate(label) );
+ break;
+ }
+ ++c;
+ }
+}
+
+void Glade2Ui::emitGtkComboChildWidgets(
+ const QValueList<QDomElement>& childWidgets, const QStringList& items )
+{
+ QString text;
+
+ // there should be exactly one child, of type GtkEntry
+ if ( childWidgets.count() == 1 ) {
+ QDomNode n = childWidgets.first().firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("name") ) {
+ // grep 'elsewhere'
+ emitProperty( QString("name"),
+ fixedName(getTextValue(n).latin1()) );
+ } else if ( tagName == QString("text") ) {
+ text = getTextValue( n );
+ }
+ n = n.nextSibling();
+ }
+ }
+
+ int n = 0;
+ QStringList::ConstIterator s = items.begin();
+ while ( s != items.end() ) {
+ if ( !text.isEmpty() && *s == text )
+ emitProperty( QString("currentItem"), n );
+ n++;
+ ++s;
+ }
+
+}
+
+void Glade2Ui::emitGtkNotebookChildWidgets(
+ const QValueList<QDomElement>& childWidgets )
+{
+ QStringList tabNames;
+ QStringList tabLabels;
+
+ for ( int i = 0; i < (int) childWidgets.count(); i++ ) {
+ tabNames.push_back( QString("tab%1").arg(i + 1) );
+ tabLabels.push_back( QString("Tab %1").arg(i + 1) );
+ }
+
+ QValueList<QDomElement>::ConstIterator c;
+ c = childWidgets.begin();
+
+ QStringList::Iterator nam = tabNames.begin();
+ QStringList::Iterator lab = tabLabels.begin();
+
+ while ( c != childWidgets.end() ) {
+ QString childName;
+ QString name;
+ QString label;
+
+ QDomNode n = (*c).firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("child_name") ) {
+ childName = getTextValue( n );
+ } else if ( tagName == QString("name") ) {
+ name = getTextValue( n );
+ } else if ( tagName == QString("label") ) {
+ label = getTextValue( n );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( childName == QString("Notebook:tab") ) {
+ if ( !name.isEmpty() )
+ *nam = name;
+ if ( !label.isEmpty() )
+ *lab = label;
+ ++nam;
+ ++lab;
+ }
+ ++c;
+ }
+
+ c = childWidgets.begin();
+ while ( c != childWidgets.end() ) {
+ QString childName;
+ QString name;
+ QString label;
+
+ QDomNode n = (*c).firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("child_name") )
+ childName = getTextValue( n );
+ n = n.nextSibling();
+ }
+
+ if ( childName != QString("Notebook:tab") ) {
+ emitOpeningWidget( QString("QWidget") );
+ emitProperty( QString("name"), tabNames.first().latin1() );
+ tabNames.remove( tabNames.begin() );
+ emitAttribute( QString("title"), accelerate(tabLabels.first()) );
+ tabLabels.remove( tabLabels.begin() );
+ emitWidget( *c, FALSE );
+ emitClosing( QString("widget") );
+ }
+ ++c;
+ }
+}
+
+void Glade2Ui::emitQListViewColumns( const QDomElement& qlistview )
+{
+ QDomNode n = qlistview.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("widget") ) {
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ QString tagName = child.toElement().tagName();
+ if ( tagName == QString("label") ) {
+ emitOpening( QString("column") );
+ emitProperty( QString("text"),
+ decelerate(getTextValue(child)) );
+ emitClosing( QString("column") );
+ }
+ child = child.nextSibling();
+ }
+ } else if ( tagName == QString("class") ) {
+ QString gtkClass = getTextValue( n );
+ if ( gtkClass.endsWith(QString("Tree")) )
+ emitProperty( QString("rootIsDecorated"), QVariant(TRUE, 0) );
+ } else if ( tagName == QString("selection_mode") ) {
+ emitProperty( QString("selectionMode"),
+ gtk2qtSelectionMode(getTextValue(n)) );
+ }
+ n = n.nextSibling();
+ }
+}
+
+void Glade2Ui::emitGtkScrolledWindowChildWidgets(
+ const QValueList<QDomElement>& childWidgets, const QString& qtClass )
+{
+ if ( childWidgets.count() == 1 ) {
+ if ( qtClass == QString("QIconView") ||
+ qtClass == QString("QListBox") ||
+ qtClass == QString("QListView") ) {
+ QDomNode n = childWidgets.first().firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("selection_mode") ) {
+ emitProperty( QString("selectionMode"),
+ gtk2qtSelectionMode(getTextValue(n)) );
+ }
+ n = n.nextSibling();
+ }
+ }
+
+ if ( qtClass == QString("QListView") ) {
+ emitQListViewColumns( childWidgets.first() );
+ } else if ( qtClass == QString("QTextEdit") ||
+ qtClass == QString("QTextView") ) {
+ QDomNode n = childWidgets.first().firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("text") )
+ emitProperty( QString("text"), getTextValue(n) );
+ n = n.nextSibling();
+ }
+ }
+ }
+}
+
+void Glade2Ui::emitGnomeDruidPage( const QDomElement& druidPage )
+{
+ QValueList<QDomElement> childWidgets;
+ QString gtkClass;
+ QString logoImage;
+ QString name;
+ QString text;
+ QString title;
+ QString watermarkImage;
+
+ emitOpeningWidget( QString("QWidget") );
+
+ QDomNode n = druidPage.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("class") ) {
+ gtkClass = getTextValue( n );
+ } else if ( tagName == QString("logo_image") ) {
+ logoImage = getTextValue( n );
+ } else if ( tagName == QString("name") ) {
+ name = getTextValue( n );
+ } else if ( tagName == QString("text") ) {
+ text = getTextValue( n );
+ } else if ( tagName == QString("title") ) {
+ title = getTextValue( n );
+ } else if ( tagName == QString("watermark_image") ) {
+ watermarkImage = getTextValue( n );
+ } else if ( tagName == QString("widget") ) {
+ childWidgets.push_back( n.toElement() );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( !name.isEmpty() )
+ emitProperty( QString("name"), fixedName(name).latin1() );
+ if ( title.isEmpty() )
+ title = QString( "Page" );
+ emitAttribute( QString("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( QString("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(QString("Standard")) ) {
+ emitChildWidgets( childWidgets, layouted, leftAttach, rightAttach,
+ topAttach, bottomAttach );
+ } else if ( !text.isEmpty() ) {
+ if ( layouted )
+ emitOpeningWidget( QString("QLayoutWidget"), leftAttach,
+ rightAttach, topAttach, bottomAttach );
+ emitOpening( QString("hbox") );
+ emitSpacer( QString("Horizontal") );
+ emitOpeningWidget( QString("QLabel") );
+ emitProperty( QString("text"), text );
+ emitClosing( QString("widget") );
+ emitSpacer( QString("Horizontal") );
+ emitClosing( QString("hbox") );
+ if ( layouted )
+ emitClosing( QString("widget") );
+ }
+
+ if ( layouted )
+ emitClosing( QString("grid") );
+ emitClosing( QString("widget") );
+}
+
+void Glade2Ui::emitGtkWindowChildWidgets(
+ const QValueList<QDomElement>& childWidgets, const QString& qtClass )
+{
+ if ( childWidgets.count() == 1 && qtClass == QString("QWizard") ) {
+ emitFontProperty( QString("titleFont"), 18, FALSE );
+
+ QDomNode n = childWidgets.first().firstChild();
+ while ( !n.isNull() ) {
+ if ( n.toElement().tagName() == QString("widget") )
+ emitGnomeDruidPage( n.toElement() );
+ n = n.nextSibling();
+ }
+ } else {
+ emitChildWidgets( childWidgets, FALSE );
+ }
+}
+
+bool Glade2Ui::packEnd( const QDomElement& widget )
+{
+ QDomNode n = widget.firstChild();
+ while ( !n.isNull() ) {
+ if ( n.toElement().tagName() == QString("child") ) {
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ if ( child.toElement().tagName() == QString("pack") ) {
+ QString pack = getTextValue( child );
+ return pack.endsWith( QString("_END") );
+ }
+ child = child.nextSibling();
+ }
+ }
+ n = n.nextSibling();
+ }
+ return FALSE;
+}
+
+void Glade2Ui::emitChildWidgets( const QValueList<QDomElement>& childWidgets,
+ bool layouted, int leftAttach, int rightAttach,
+ int topAttach, int bottomAttach )
+{
+ QValueList<QDomElement> start;
+ QValueList<QDomElement> end;
+ QValueList<QDomElement>::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 QString& qtClass, int leftAttach,
+ int rightAttach, int topAttach,
+ int bottomAttach )
+{
+ AttributeMap attr = attribute( QString("class"), qtClass );
+ attach( &attr, leftAttach, rightAttach, topAttach, bottomAttach );
+ emitOpening( QString("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 QValueList<QDomElement>& childWidgets )
+{
+ QRegExp gtkSmallWidget( QString(
+ "G.*(?:Button|Combo|Dial|Entry|Label|OptionMenu|Picker|ProgressBar"
+ "|Separator|Statusbar|Toolbar|VBox)") );
+
+ QValueList<QDomElement>::ConstIterator c = childWidgets.begin();
+ while ( c != childWidgets.end() ) {
+ QValueList<QDomElement> grandchildWidgets;
+ QString gtkClass;
+
+ QDomNode n = (*c).firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+ if ( tagName == QString("class") ) {
+ gtkClass = getTextValue( n );
+ } else if ( tagName == QString("widget") ) {
+ grandchildWidgets.push_back( n.toElement() );
+ }
+ n = n.nextSibling();
+ }
+
+ if ( !gtkSmallWidget.exactMatch(gtkClass) ||
+ !shouldPullup(grandchildWidgets) )
+ return FALSE;
+ ++c;
+ }
+ return TRUE;
+}
+
+QString Glade2Ui::emitWidget( const QDomElement& widget, bool layouted,
+ int leftAttach, int rightAttach, int topAttach,
+ int bottomAttach )
+{
+ QRegExp gtkLayoutWidget( QString(
+ "Gtk(?:Packer|Table|Toolbar|[HV](?:(?:Button)?Box))") );
+ QRegExp gtkOrientedWidget( QString(
+ "Gtk([HV])(?:Paned|Scale|Scrollbar|Separator)") );
+
+ QValueList<QDomElement> childWidgets;
+ QString gtkClass;
+ QString name;
+ QString title;
+ int x = 0;
+ int y = 0;
+ int width = 0;
+ int height = 0;
+ int numRows = 0;
+ int numColumns = 0;
+
+ bool active = FALSE;
+ QString authors;
+ QString childName;
+ QString comments;
+ QString copyright;
+ QString creationFunction;
+ bool editable = TRUE;
+ QString filename;
+ QString focusTarget;
+ QString hscrollbarPolicy;
+ QString icon;
+ int initialChoice = 0;
+ QStringList items;
+ QString justify;
+ QString label;
+ QString logoImage;
+ int lower = -123456789;
+ int page = 10;
+ int pageSize = 10;
+ QString selectionMode;
+ QString shadowType( "GTK_SHADOW_NONE" );
+ bool showText = TRUE;
+ bool showTitles = TRUE;
+ int step = 1;
+ QString tabPos;
+ QString text;
+ int textMaxLength = 0;
+ bool textVisible = TRUE;
+ QString tooltip;
+ QString type;
+ int upper = 123456789;
+ int value = 123456789;
+ bool valueInList = TRUE;
+ QString vscrollbarPolicy;
+ QString watermarkImage;
+ bool wrap = FALSE;
+
+ bool topLevel = yyFormName.isEmpty();
+ if ( topLevel )
+ name = QString( "Form%1" ).arg( uniqueForm++ );
+
+ QDomNode n = widget.firstChild();
+ while ( !n.isNull() ) {
+ QString 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 == QString("active") ) {
+ active = isTrue( getTextValue(n) );
+ } else if ( tagName == QString("authors") ) {
+ authors = getTextValue( n );
+ }
+ break;
+ case 'c':
+ if ( tagName == QString("child") ) {
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ QString childTagName = child.toElement().tagName();
+ if ( childTagName == QString("left_attach") ) {
+ leftAttach = getTextValue( child ).toInt();
+ } else if ( childTagName == QString("right_attach") ) {
+ rightAttach = getTextValue( child ).toInt();
+ } else if ( childTagName == QString("top_attach") ) {
+ topAttach = getTextValue( child ).toInt();
+ } else if ( childTagName == QString("bottom_attach") ) {
+ bottomAttach = getTextValue( child ).toInt();
+ }
+ child = child.nextSibling();
+ }
+ } else if ( tagName == QString("child_name") ) {
+ childName = getTextValue( n );
+ } else if ( tagName == QString("class") ) {
+ gtkClass = getTextValue( n );
+ } else if ( tagName == QString("climb_rate") ) {
+ step = getTextValue( n ).toInt();
+ } else if ( tagName == QString("columns") ) {
+ numColumns = getTextValue( n ).toInt();
+ } else if ( tagName == QString("comments") ) {
+ comments = getTextValue( n );
+ } else if ( tagName == QString("copyright") ) {
+ copyright = getTextValue( n );
+ } else if ( tagName == QString("creation_function") ) {
+ creationFunction = getTextValue( n );
+ }
+ break;
+ case 'd':
+ if ( tagName == QString("default_focus_target") ) {
+ if ( focusTarget.isEmpty() )
+ focusTarget = getTextValue( n );
+ }
+ break;
+ case 'e':
+ if ( tagName == QString("editable") )
+ editable = isTrue( getTextValue(n) );
+ break;
+ case 'f':
+ if ( tagName == QString("filename") ) {
+ filename = getTextValue( n );
+ } else if ( tagName == QString("focus_target") ) {
+ focusTarget = getTextValue( n );
+ }
+ break;
+ case 'h':
+ if ( tagName == QString("height") ) {
+ height = getTextValue( n ).toInt();
+ } else if ( tagName == QString("hscrollbar_policy") ) {
+ hscrollbarPolicy = getTextValue( n );
+ }
+ break;
+ case 'i':
+ if ( tagName == QString("icon") ) {
+ icon = getTextValue( n );
+ } else if ( tagName == QString("initial_choice") ) {
+ initialChoice = getTextValue( n ).toInt();
+ } else if ( tagName == QString("items") ) {
+ items = QStringList::split( QChar('\n'), getTextValue(n) );
+ }
+ break;
+ case 'j':
+ if ( tagName == QString("justify") )
+ justify = getTextValue( n );
+ break;
+ case 'l':
+ if ( tagName == QString("label") ) {
+ label = getTextValue( n );
+ } else if ( tagName == QString("logo_image") ) {
+ logoImage = getTextValue( n );
+ } else if ( tagName == QString("lower") ) {
+ lower = getTextValue( n ).toInt();
+ }
+ break;
+ case 'n':
+ if ( tagName == QString("name") )
+ name = getTextValue( n );
+ break;
+ case 'p':
+ if ( tagName == QString("page") ) {
+ page = getTextValue( n ).toInt();
+ } else if ( tagName == QString("page_size") ) {
+ pageSize = getTextValue( n ).toInt();
+ }
+ break;
+ case 'r':
+ if ( tagName == QString("rows") )
+ numRows = getTextValue( n ).toInt();
+ break;
+ case 's':
+ if ( tagName == QString("selection_mode") ) {
+ selectionMode = getTextValue( n );
+ } else if ( tagName == QString("shadow_type") ) {
+ shadowType = getTextValue( n );
+ } else if ( tagName == QString("show_text") ) {
+ showText = isTrue( getTextValue(n) );
+ } else if ( tagName == QString(QString("show_titles")) ) {
+ showTitles = isTrue( getTextValue(n) );
+ } else if ( tagName == QString("step") ) {
+ step = getTextValue( n ).toInt();
+ } else if ( tagName == QString("stock_button") ) {
+ /*
+ Let's cheat: We convert the symbolic name into a
+ button label.
+ */
+ label = getTextValue( n );
+ int k = label.findRev( QChar('_') );
+ if ( k != -1 )
+ label = label.mid( k + 1 );
+ if ( !label.isEmpty() && label != QString("OK") )
+ label = label.left( 1 ) + label.mid( 1 ).lower();
+ }
+ break;
+ case 't':
+ if ( tagName == QString("tab_pos") ) {
+ tabPos = getTextValue( n );
+ } else if ( tagName == QString("text") ) {
+ text = getTextValue( n );
+ } else if ( tagName == QString("textMaxLength") ) {
+ textMaxLength = getTextValue( n ).toInt();
+ } else if ( tagName == QString("textVisible") ) {
+ textVisible = isTrue( getTextValue(n) );
+ } else if ( tagName == QString("title") ) {
+ title = getTextValue( n );
+ } else if ( tagName == QString("tooltip") ) {
+ tooltip = getTextValue( n );
+ } else if ( tagName == QString("type") ) {
+ type = getTextValue( n );
+ }
+ break;
+ case 'u':
+ if ( tagName == QString("upper") )
+ upper = getTextValue( n ).toInt();
+ break;
+ case 'v':
+ if ( tagName == QString("value") ) {
+ value = getTextValue( n ).toInt();
+ } else if ( tagName == QString("value_in_list") ) {
+ valueInList = isTrue( getTextValue(n) );
+ } else if ( tagName == QString("vscrollbar_policy") ) {
+ vscrollbarPolicy = getTextValue( n );
+ }
+ break;
+ case 'w':
+ if ( tagName == QString("watermark_image") ) {
+ watermarkImage = getTextValue( n );
+ } else if ( tagName == QString("widget") )
+ childWidgets.push_back( n.toElement() );
+ else if ( tagName == QString("width") )
+ width = getTextValue( n ).toInt();
+ else if ( tagName == QString("wrap") )
+ wrap = isTrue( getTextValue(n) );
+ break;
+ case 'x':
+ if ( tagName == QString("x") )
+ x = getTextValue( n ).toInt();
+ break;
+ case 'y':
+ if ( tagName == QString("y") )
+ y = getTextValue( n ).toInt();
+ }
+ }
+ n = n.nextSibling();
+ }
+
+ if ( topLevel ) {
+ yyFormName = name;
+ emitSimpleValue( QString("class"), yyFormName );
+ }
+
+ if ( gtkLayoutWidget.exactMatch(gtkClass) ) {
+ QString boxKind;
+ QString orientation;
+
+ if ( gtkClass.startsWith(QString("GtkH")) ||
+ gtkClass == QString(QString("GtkToolbar")) ) {
+ /*
+ GtkToolbar, right. Toolbars may appear anywhere in a
+ widget, but then they really are just a row of buttons.
+ */
+ boxKind = QString( "hbox" );
+ orientation = QString( "Horizontal" );
+ } else if ( gtkClass.startsWith(QString("GtkV")) ||
+ gtkClass == QString("GtkPacker") ) {
+ /*
+ We don't support the GtkPacker, whose trails lead to
+ destruction.
+ */
+ boxKind = QString( "vbox" );
+ orientation = QString( "Vertical" );
+ } else {
+ boxKind = QString( "grid" );
+ }
+
+ if ( layouted )
+ emitOpeningWidget( QString("QLayoutWidget"), leftAttach,
+ rightAttach, topAttach, bottomAttach );
+ emitOpening( boxKind );
+ emitProperty( QString("name"), fixedName(name).latin1() );
+ if ( gtkClass == QString("GtkHButtonBox") ||
+ childName == QString("Dialog:action_area") )
+ emitSpacer( orientation );
+ emitChildWidgets( childWidgets, TRUE );
+
+ if ( gtkClass == QString("GtkVButtonBox") ||
+ childName == QString("Dialog:action_area") ||
+ (boxKind == QString("vbox") && shouldPullup(childWidgets)) ) {
+ emitSpacer( orientation );
+ } else if ( boxKind == QString("grid") && shouldPullup(childWidgets) ) {
+ emitSpacer( QString("Vertical"), 0, numColumns, numRows,
+ numRows + 1 );
+ }
+
+ emitClosing( boxKind );
+ if ( layouted )
+ emitClosing( QString("widget") );
+ } else if ( gtkClass == QString("GtkFixed") && !layouted ) {
+ emitChildWidgets( childWidgets, FALSE );
+ /*
+ Placeholders in a grid are typically needless.
+ */
+ } else if ( !(leftAttach >= 0 && gtkClass == QString("Placeholder")) ) {
+ bool needFakeLayout = ( !layouted && !topLevel && x == 0 && y == 0 &&
+ width == 0 && height == 0 );
+ QString qtClass = gtk2qtClass( gtkClass, childWidgets );
+ bool unknown = FALSE;
+
+ if ( qtClass == QString("QFrame") && !label.isEmpty() ) {
+ qtClass = QString( "QButtonGroup" );
+ } else if ( qtClass == QString("QListView") && !showTitles &&
+ gtkClass.endsWith(QString("List")) ) {
+ qtClass = QString( "QListBox" );
+ } else if ( qtClass == QString("Custom") ) {
+ qtClass = creationFunction;
+ yyCustomWidgets.insert( qtClass, QString::null );
+ } else if ( qtClass == QString("Unknown") ) {
+ qtClass = QString( "QLabel" );
+ unknown = TRUE;
+ }
+
+ if ( qtClass.isEmpty() ) {
+ emitChildWidgets( childWidgets, layouted, leftAttach, rightAttach,
+ topAttach, bottomAttach );
+ } else {
+ if ( needFakeLayout ) {
+ emitOpening( QString("vbox") );
+ emitProperty( QString("margin"), 11 );
+ }
+ emitOpeningWidget( qtClass, leftAttach, rightAttach, topAttach,
+ bottomAttach );
+
+ // grep 'elsewhere'
+ if ( gtkClass != QString("GtkCombo") )
+ emitProperty( QString("name"), fixedName(name).latin1() );
+ if ( !title.isEmpty() )
+ emitProperty( QString("caption"), title );
+ if ( !layouted && (x != 0 || y != 0 || width != 0 || height != 0) )
+ emitProperty( QString("geometry"), QRect(x, y, width, height) );
+ if ( gtkClass == QString("GtkToggleButton") ) {
+ emitProperty( QString("toggleButton"), QVariant(TRUE, 0) );
+ if ( active )
+ emitProperty( QString("on"), QVariant(TRUE, 0) );
+ } else {
+ if ( active )
+ emitProperty( QString("checked"), QVariant(TRUE, 0) );
+ }
+
+ if ( !editable )
+ emitProperty( QString("readOnly"), QVariant(TRUE, 0) );
+ if ( !focusTarget.isEmpty() )
+ emitProperty( QString("buddy"),
+ fixedName(focusTarget).latin1() );
+ if ( !hscrollbarPolicy.isEmpty() )
+ emitProperty( QString("hScrollBarMode"),
+ gtk2qtScrollBarMode(hscrollbarPolicy),
+ QString("enum") );
+ if ( !vscrollbarPolicy.isEmpty() )
+ emitProperty( QString("vScrollBarMode"),
+ gtk2qtScrollBarMode(vscrollbarPolicy),
+ QString("enum") );
+ if ( !justify.isEmpty() ||
+ (wrap && gtkClass != QString("GtkSpinButton")) ) {
+ QStringList flags;
+ if ( wrap )
+ flags.push_back( QString("WordBreak") );
+
+ if ( justify.endsWith(QString("_CENTER")) ) {
+ flags.push_back( QString("AlignCenter") );
+ } else {
+ if ( justify.endsWith(QString("_RIGHT")) )
+ flags.push_back( QString("AlignRight") );
+ flags.push_back( QString("AlignVCenter") );
+ }
+
+ if ( !flags.isEmpty() )
+ emitProperty( QString("alignment"), flags.join(QChar('|')),
+ QString("set") );
+ }
+ if ( !label.isEmpty() ) {
+ if ( gtkClass.endsWith(QString("Frame")) ) {
+ emitProperty( QString("title"), label );
+ } else {
+ emitProperty( QString("text"), accelerate(label) );
+ }
+ }
+ if ( lower != -123456789 )
+ emitProperty( QString("minValue"), lower );
+ if ( upper != 123456789 )
+ emitProperty( QString("maxValue"), upper );
+ if ( value != 123456789 ) {
+ if ( gtkClass == QString("GtkProgressBar") ) {
+ emitProperty( QString("progress"), value );
+ } else {
+ emitProperty( QString("value"), value );
+ }
+ }
+ if ( QMAX(page, pageSize) != 10 &&
+ gtkClass.endsWith(QString("Scrollbar")) )
+ emitProperty( QString("pageStep"), QMAX(page, pageSize) );
+ if ( !selectionMode.isEmpty() )
+ emitProperty( QString("selectionMode"),
+ gtk2qtSelectionMode(selectionMode),
+ QString("enum") );
+ if ( !shadowType.endsWith(QString("_NONE")) ) {
+ QString shape = shadowType.contains( QString("_ETCHED_") ) > 0 ?
+ QString( "Box" ) : QString( "WinPanel" );
+ QString shadow = shadowType.endsWith( QString("_IN") ) ?
+ QString( "Sunken" ) : QString( "Raised" );
+ emitProperty( QString("frameShape"), shape, QString("enum") );
+ emitProperty( QString("frameShadow"), shadow, QString("enum") );
+ }
+ if ( !showText )
+ emitProperty( QString("percentageVisible"),
+ QVariant(FALSE, 0) );
+ if ( step != 1 )
+ emitProperty( QString("lineStep"), step );
+ if ( tabPos.endsWith(QString("_BOTTOM")) ||
+ tabPos.endsWith(QString("_RIGHT")) )
+ emitProperty( QString("tabPosition"), QString("Bottom") );
+ if ( !text.isEmpty() )
+ emitProperty( QString("text"), text );
+ if ( textMaxLength != 0 )
+ emitProperty( QString("maxLength"), textMaxLength );
+ if ( !textVisible )
+ emitProperty( QString("echoMode"), QString("Password"),
+ QString("enum") );
+ if ( !tooltip.isEmpty() )
+ emitProperty( QString("toolTip"), tooltip );
+ if ( !valueInList )
+ emitProperty( QString("editable"), QVariant(TRUE, 0) );
+ if ( wrap && gtkClass == QString("GtkSpinButton") )
+ emitProperty( QString("wrapping"), QVariant(TRUE, 0) );
+
+ if ( gtkClass.endsWith(QString("Tree")) ) {
+ emitProperty( QString("rootIsDecorated"), QVariant(TRUE, 0) );
+ } else if ( gtkOrientedWidget.exactMatch(gtkClass) ) {
+ QString s = ( gtkOrientedWidget.cap(1) == QChar('H') ) ?
+ QString( "Horizontal" ) : QString( "Vertical" );
+ emitProperty( QString("orientation"), s, QString("enum") );
+ }
+
+ if ( qtClass == QString("QListView") )
+ emitProperty( QString("resizeMode"), QString("AllColumns"),
+ QString("enum") );
+
+ while ( !items.isEmpty() ) {
+ emitOpening( QString("item") );
+ emitProperty( QString("text"), items.first() );
+ emitClosing( QString("item") );
+ items.remove( items.begin() );
+ }
+ if ( initialChoice != 0 )
+ emitProperty( QString("currentItem"), initialChoice );
+
+ if ( !icon.isEmpty() )
+ emitProperty( QString("pixmap"), imageName(icon),
+ QString("pixmap") );
+
+ if ( gtkClass == QString("GnomeAbout") ) {
+ emitGnomeAbout( copyright, authors, comments );
+ } else if ( gtkClass == QString("GnomeApp") ) {
+ emitGnomeAppChildWidgetsPass1( childWidgets );
+ } else if ( gtkClass == QString("GnomePropertyBox") ) {
+ emitOpening( QString("vbox") );
+ emitChildWidgets( childWidgets, TRUE );
+ emitOpeningWidget( QString("QLayoutWidget") );
+ emitOpening( QString("hbox") );
+ emitPushButton( QString("&Help"), QString("helpButton") );
+ emitSpacer( QString("Horizontal") );
+ emitPushButton( QString("&OK"), QString("okButton") );
+ emitPushButton( QString("&Apply"), QString("applyButton") );
+ emitPushButton( QString("&Close"), QString("closeButton") );
+ emitClosing( QString("hbox") );
+ emitClosing( QString("widget") );
+ emitClosing( QString("vbox") );
+ } else if ( gtkClass.endsWith(QString("Button")) ) {
+ if ( label.isEmpty() )
+ emitGtkButtonChildWidgets( childWidgets );
+ } else if ( gtkClass == QString("GtkCombo") ) {
+ emitGtkComboChildWidgets( childWidgets, items );
+ } else if ( gtkClass == QString("GtkNotebook") ) {
+ emitGtkNotebookChildWidgets( childWidgets );
+ } else if ( gtkClass == QString("GtkWindow") ) {
+ emitGtkWindowChildWidgets( childWidgets, qtClass );
+ } else if ( gtkClass == QString("GtkScrolledWindow") ) {
+ emitGtkScrolledWindowChildWidgets( childWidgets, qtClass );
+ } else if ( qtClass == QString("QListView") ) {
+ emitQListViewColumns( widget );
+ } else if ( unknown || gtkClass == QString("Placeholder") ) {
+ QString prefix;
+ if ( unknown )
+ prefix = gtkClass;
+ emitProperty( QString("text"),
+ QString("<font color=\"red\">%1<b>?</b></font>")
+ .arg(prefix) );
+ emitProperty( QString("alignment"),
+ QString("AlignAuto|AlignCenter"),
+ QString("set") );
+ } else if ( qtClass != QString("QListBox") ) {
+ emitChildWidgets( childWidgets, FALSE );
+ }
+
+ emitClosing( QString("widget") );
+ if ( needFakeLayout )
+ emitClosing( QString("vbox") );
+ if ( gtkClass == QString("GnomeApp") )
+ emitGnomeAppChildWidgetsPass2( childWidgets );
+ }
+ }
+ return name;
+}
+
+QStringList Glade2Ui::convertGladeFile( const QString& fileName )
+{
+ QStringList outFileNames;
+
+ yyFileName = fileName;
+
+ QDomDocument doc( QString("GTK-Interface") );
+ QFile f( fileName );
+ if ( !f.open(IO_ReadOnly) ) {
+ error( QString("Cannot open file for reading.") );
+ return QStringList();
+ }
+ if ( !doc.setContent(&f) ) {
+ error( QString("File is not an XML file.") );
+ f.close();
+ return QStringList();
+ }
+ f.close();
+
+ QDomElement root = doc.documentElement();
+ if ( root.tagName() != QString("GTK-Interface") ) {
+ error( QString("File is not a Glade XML file.") );
+ return QStringList();
+ }
+
+ int widgetNo = 0;
+ int numWidgets = 0;
+ QDomNode n = root.firstChild();
+ while ( !n.isNull() ) {
+ if ( n.toElement().tagName() == QString("widget") )
+ numWidgets++;
+ n = n.nextSibling();
+ }
+
+ QProgressDialog fremskritt( QString("Converting Glade files..."),
+ QString("Abort Conversion"), numWidgets, 0,
+ "fremskritt", TRUE );
+
+ n = root.firstChild();
+ while ( !n.isNull() ) {
+ QString tagName = n.toElement().tagName();
+
+ if ( tagName == QString("project") ) {
+ QDomNode child = n.firstChild();
+ while ( !child.isNull() ) {
+ QString childTagName = child.toElement().tagName();
+ if ( childTagName == QString("pixmaps_directory") ) {
+ yyPixmapDirectory = getTextValue( child );
+ } else if ( childTagName == QString("program_name") ) {
+ yyProgramName = getTextValue( child );
+ }
+ child = child.nextSibling();
+ }
+ } else if ( tagName == QString("widget") ) {
+ yyOut = QString::null;
+ yyCustomWidgets.clear();
+ yyStockItemActions.clear();
+ yyActions.clear();
+ yyConnections.clear();
+ yySlots.clear();
+ yyFormName = QString::null;
+ yyImages.clear();
+
+ uniqueAction = 1;
+ uniqueForm = 1;
+ uniqueMenuBar = 1;
+ uniqueSpacer = 1;
+ uniqueToolBar = 1;
+
+ emitHeader();
+ QString name = emitWidget( n.toElement(), FALSE );
+
+ if ( !yyCustomWidgets.isEmpty() ) {
+ emitOpening( QString("customwidgets") );
+
+ QMap<QString, QString>::Iterator c = yyCustomWidgets.begin();
+ while ( c != yyCustomWidgets.end() ) {
+ emitOpening( QString("customwidget") );
+ emitSimpleValue( QString("class"), c.key() );
+ if ( !(*c).isEmpty() )
+ emitSimpleValue( QString("header"), *c,
+ attribute(QString("location"),
+ QString("local")) );
+ emitClosing( QString("customwidget") );
+ ++c;
+ }
+ emitClosing( QString("customwidgets") );
+ }
+
+ if ( !yyActions.isEmpty() ) {
+ emitOpening( QString("actions") );
+
+ QMap<QString, GladeAction>::Iterator a = yyActions.begin();
+ while ( a != yyActions.end() ) {
+ emitOpening( QString("action") );
+ emitProperty( QString("name"),
+ fixedName(a.key()).latin1() );
+ emitProperty( QString("text"), (*a).text );
+ emitProperty( QString("menuText"), (*a).menuText );
+ if ( (*a).toolTip )
+ emitProperty( QString("toolTip"), (*a).toolTip );
+ if ( (*a).accel != 0 )
+ emitProperty( QString("accel"), (*a).accel );
+ if ( !(*a).iconSet.isEmpty() )
+ emitProperty( QString("iconSet"),
+ imageName((*a).iconSet),
+ QString("iconset") );
+ emitClosing( QString("action") );
+ ++a;
+ }
+ emitClosing( QString("actions") );
+ }
+
+ if ( !yyImages.isEmpty() ) {
+ uint maxLength = 524288;
+ char *data = new char[maxLength];
+
+ QString dir = yyFileName;
+ dir.truncate( dir.findRev(QChar('/')) + 1 );
+ dir += yyPixmapDirectory;
+
+ emitOpening( QString("images") );
+
+ QMap<QString, QString>::ConstIterator im = yyImages.begin();
+ while ( im != yyImages.end() ) {
+ uint length = 0;
+ const char *format = 0;
+
+ QString fn = dir + QChar( '/' ) + im.key();
+ QFile f( fn );
+ if ( !f.open(IO_ReadOnly) ) {
+ error( QString("Cannot open image '%1' for reading.")
+ .arg(fn) );
+ } else {
+ length = f.readBlock( data, maxLength );
+ f.at( 0 );
+ format = QImageIO::imageFormat( &f );
+ f.close();
+ }
+ if ( format == 0 )
+ format = "XPM";
+
+ AttributeMap attr;
+ attr.insert( QString("format"), QString(format) );
+ attr.insert( QString("length"), QString::number(length) );
+
+ emitOpening( QString("image"),
+ attribute(QString("name"), *im) );
+ emitSimpleValue( QString("data"), hexed(data, length),
+ attr );
+ emitClosing( QString("image") );
+ ++im;
+ }
+ emitClosing( QString("images") );
+ delete[] data;
+ }
+
+ if ( yyConnections.count() + yySlots.count() > 0 ) {
+ emitOpening( QString("connections") );
+
+ QValueList<GladeConnection>::Iterator c = yyConnections.begin();
+ while ( c != yyConnections.end() ) {
+ emitOpening( QString("connection") );
+ emitSimpleValue( QString("sender"), (*c).sender );
+ emitSimpleValue( QString("signal"), (*c).signal );
+ emitSimpleValue( QString("receiver"), yyFormName );
+ emitSimpleValue( QString("slot"), (*c).slot );
+ emitClosing( QString("connection") );
+ ++c;
+ }
+
+ QMap<QString, QString>::Iterator s = yySlots.begin();
+ while ( s != yySlots.end() ) {
+ AttributeMap attr;
+ attr.insert( QString("access"), *s );
+ attr.insert( QString("language"), QString("C++") );
+ attr.insert( QString("returntype"), QString("void") );
+ emitSimpleValue( QString("slot"), s.key(), attr );
+ ++s;
+ }
+ emitClosing( QString("connections") );
+ }
+ emitFooter();
+
+ QString outFileName = fileName;
+ int k = outFileName.findRev( "." );
+ if ( k != -1 )
+ outFileName.truncate( k );
+ if ( widgetNo != 0 )
+ outFileName += QString::number( widgetNo + 1 );
+ outFileName += QString( ".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 = QString::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 0000000..e688428
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QMap<QString, QString> AttributeMap;
+
+struct GladeAction
+{
+ QString text;
+ QString menuText;
+ QString toolTip;
+ int accel;
+ QString iconSet;
+};
+
+struct GladeConnection
+{
+ QString sender;
+ QString signal;
+ QString slot;
+};
+
+class Glade2Ui
+{
+public:
+ Glade2Ui();
+
+ QStringList convertGladeFile( const QString& fileName );
+
+private:
+ QString imageName( const QString& fileName );
+ QString opening( const QString& tag,
+ const AttributeMap& attr = AttributeMap() );
+ QString closing( const QString& tag );
+ QString atom( const QString& tag,
+ const AttributeMap& attr = AttributeMap() );
+ void error( const QString& message );
+ void syntaxError();
+ QString getTextValue( const QDomNode& node );
+ void emitHeader();
+ void emitFooter();
+ void emitSimpleValue( const QString& tag, const QString& value,
+ const AttributeMap& attr = AttributeMap() );
+ void emitOpening( const QString& tag,
+ const AttributeMap& attr = AttributeMap() );
+ void emitClosing( const QString& tag );
+ void emitAtom( const QString& tag,
+ const AttributeMap& attr = AttributeMap() );
+ void emitVariant( const QVariant& val,
+ const QString& stringType = "string" );
+ void emitProperty( const QString& prop, const QVariant& val,
+ const QString& stringType = "string" );
+ void emitFontProperty( const QString& prop, int pointSize, bool bold );
+ void emitAttribute( const QString& prop, const QVariant& val,
+ const QString& stringType = "string" );
+ QString gtk2qtClass( const QString& gtkClass,
+ const QValueList<QDomElement>& childWidgets );
+
+ int matchAccelOnActivate( const QDomElement& accel );
+ void emitGtkMenu( const QDomElement& menu );
+ void emitGtkMenuBarChildWidgets(
+ const QValueList<QDomElement>& childWidgets );
+ void emitGtkToolbarChildWidgets(
+ const QValueList<QDomElement>& childWidgets );
+ void emitPushButton( const QString& text, const QString& name );
+ void attach( AttributeMap *attr, int leftAttach, int rightAttach,
+ int topAttach, int bottomAttach );
+ void emitSpacer( const QString& orientation, int leftAttach = -1,
+ int rightAttach = -1, int topAttach = -1,
+ int bottomAttach = -1 );
+ void emitPixmap( const QString& imageName, int leftAttach = -1,
+ int rightAttach = -1, int topAttach = -1,
+ int bottomAttach = -1 );
+ void emitGnomeAbout( QString copyright, QString authors, QString comments );
+ void emitGnomeAppChildWidgetsPass1(
+ const QValueList<QDomElement>& childWidgets );
+ void doPass2( const QValueList<QDomElement>& childWidgets,
+ QValueList<QDomElement> *menuBar,
+ QValueList<QValueList<QDomElement> > *toolBars );
+ void emitGnomeAppChildWidgetsPass2(
+ const QValueList<QDomElement>& childWidgets );
+ void emitGtkButtonChildWidgets( QValueList<QDomElement> childWidgets );
+ void emitGtkComboChildWidgets( const QValueList<QDomElement>& childWidgets,
+ const QStringList& items );
+ void emitGtkNotebookChildWidgets(
+ const QValueList<QDomElement>& childWidgets );
+ void emitQListViewColumns( const QDomElement& qlistview );
+ void emitGtkScrolledWindowChildWidgets(
+ const QValueList<QDomElement>& childWidgets,
+ const QString& qtClass );
+ void emitGnomeDruidPage( const QDomElement& druidPage );
+ void emitGtkWindowChildWidgets( const QValueList<QDomElement>& childWidgets,
+ const QString& qtClass );
+ bool packEnd( const QDomElement& widget );
+ void emitChildWidgets( const QValueList<QDomElement>& childWidgets,
+ bool layouted, int leftAttach = -1,
+ int rightAttach = -1, int topAttach = -1,
+ int bottomAttach = -1 );
+ void emitOpeningWidget( const QString& qtClass, int leftAttach = -1,
+ int rightAttach = -1, int topAttach = -1,
+ int bottomAttach = -1 );
+ bool shouldPullup( const QValueList<QDomElement>& childWidgets );
+ QString emitWidget( const QDomElement& widget, bool layouted,
+ int leftAttach = -1, int rightAttach = -1,
+ int topAttach = -1, int bottomAttach = -1 );
+
+ QString yyOut;
+ QString yyIndentStr;
+ QString yyFileName;
+ QString yyProgramName;
+ QString yyPixmapDirectory;
+ QMap<QString, QString> yyClassNameMap;
+ QMap<QString, QString> yyStockMap;
+ QMap<QString, int> yyKeyMap;
+ QMap<QString, QString> yyCustomWidgets;
+ QMap<QString, QString> yyStockItemActions;
+ QMap<QString, GladeAction> yyActions;
+ QValueList<GladeConnection> yyConnections;
+ QMap<QString, QString> yySlots;
+ QString yyFormName;
+ QMap<QString, QString> 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 0000000..7ed71bb
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QLibraryInterface
+{
+public:
+ GladeFilter();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface **iface );
+ Q_REFCOUNT;
+
+ QStringList featureList() const;
+ QStringList import( const QString& filter, const QString& filename );
+
+ bool init();
+ void cleanup();
+ bool canUnload() const;
+
+};
+
+GladeFilter::GladeFilter()
+{
+}
+
+QRESULT GladeFilter::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)(ImportFilterInterface*)this;
+ else if ( uuid == IID_QFeatureList )
+ *iface = (QFeatureListInterface*)this;
+ else if ( uuid == IID_ImportFilter )
+ *iface = (ImportFilterInterface*)this;
+ else if ( uuid == IID_QLibrary )
+ *iface = (QLibraryInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+QStringList GladeFilter::featureList() const
+{
+ QStringList list;
+ list << "Glade Files (*.glade)" ;
+ return list;
+}
+
+QStringList GladeFilter::import( const QString &, const QString& 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 0000000..d90d646
--- /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 0000000..bce7fb2
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QString& name )
+{
+ wi(); *out << "<class>" << name << "</class>" << endl;
+}
+
+void KDEVDLG2UI::writeWidgetStart( const QString& qclass )
+{
+ wi(); *out << "<widget class=\"" << qclass << "\">" << endl;
+}
+
+void KDEVDLG2UI::writeWidgetEnd()
+{
+ wi(); *out << "</widget>" << endl;
+}
+
+void KDEVDLG2UI::writeCString( const QString& name, const QString& 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 QString& name, const QString& 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 QString& 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 QString& 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 QString& 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 QString& 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 QString& name, const QString& 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 QString& name, const QString& 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 QString& name, const QString& value )
+{
+ wi(); *out << "<item>" << endl; indent();
+ writeString( name, value ); undent();
+ wi(); *out << "</item>" << endl;
+}
+
+void KDEVDLG2UI::writeColumn( const QString& name, const QString& value )
+{
+ wi(); *out << "<column>" << endl; indent();
+ writeString( name, value ); undent();
+ wi(); *out << "</column>" << endl;
+}
+
+void KDEVDLG2UI::writeColor( const QString& name, const QString& 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 QStringList styles, bool isFrame )
+{
+ if ( isFrame ) {
+ bool defineFrame = FALSE;
+ QString shadow = "NoFrame";
+ QString 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( QTextStream* input, const QString& 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()
+{
+ QFile fileOut;
+ QString buffer;
+
+ if ( writeToFile ) {
+
+ QString outputFile = QString( className ) + ".ui";
+ fileOut.setName( outputFile );
+ if (!fileOut.open( IO_WriteOnly ) )
+ qFatal( "kdevdlg2ui: Could not open output file '%s'", outputFile.latin1() );
+ out = new QTextStream( &fileOut );
+ targetFiles.append( outputFile );
+ } else {
+ out = new QTextStream( &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( QStringList& get )
+{
+ writeToFile = FALSE;
+ bool result = parse();
+ get = target;
+ return result;
+}
+
+/*!
+ Replaces characters like '&', '<' and '>' with the proper encoding.
+*/
+void KDEVDLG2UI::cleanString( QString * text )
+{
+ if ( !text ) return;
+ text->replace( "\\n", "\n" );
+ text->replace( "\\t", "\t" );
+ text->replace( "&", "&amp;" );
+ text->replace( "<", "&lt;" );
+ text->replace( ">", "&gt;" );
+}
+
+/*!
+ Builds a number of UI dialog out of the current input stream
+*/
+bool KDEVDLG2UI::writeDialog( const QString& 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" ) {
+ QString name = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ writeString( "name", name );
+ } else if ( line.left( 4 ) == "Font" ) {
+ QString font = line.section( "//", 0, 0 ).section( "\"", 1 );
+ QString 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" ) {
+ QString text = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & text );
+ writeString( "text", text );
+ } else if ( line.left( 5 ) == "Title" ) {
+ QString title = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & title );
+ writeString( "title", title );
+ } else if ( line.left( 5 ) == "Buddy" ) {
+ QString buddy = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ writeString( "buddy", buddy );
+ } else if ( line.left( 14 ) == "SpecialValText" ) {
+ QString text = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ writeString( "specialValueText", text );
+ } else if ( line.left( 6 ) == "Prefix" ) {
+ QString text = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ writeString( "prefix", text );
+ } else if ( line.left( 6 ) == "Suffix" ) {
+ QString 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" ) {
+ QString text = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ writeString( "toolTip", text );
+ } else if ( line.left( 9 ) == "QuickHelp" ) {
+ QString text = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & text );
+ writeString( "whatsThis", text );
+ } else if ( line.left( 15 ) == "InsertionPolicy" ) {
+ QString policy = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & policy );
+ writeEnum( "insertionPolicy", policy ); //###FIX: QComboBox::
+ } else if ( line.left( 11 ) == "Orientation" ) {
+ QString orientation =
+ line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & orientation );
+ if ( orientation == "V" )
+ writeEnum( "orientation", "Qt::Vertical" );
+ else if ( orientation == "H" )
+ writeEnum( "orientation", "Qt::Horizontal" );
+ } else if ( line.left( 14 ) == "vScrollBarMode" ) {
+ QString mode = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & mode );
+ writeEnum( "vScrollBarMode", mode );
+ } else if ( line.left( 14 ) == "hScrollBarMode" ) {
+ QString mode = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & mode );
+ writeEnum( "hScrollBarMode", mode );
+ } else if ( line.left( 7 ) == "Entries" ) {
+ QString entries = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & entries );
+ QStringList l = QStringList::split( '\n', entries );
+ for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it )
+ writeItem( "text", *it );
+ } else if ( line.left( 7 ) == "Columns" ) {
+ QString columns = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & columns );
+ QStringList l = QStringList::split( '\n', columns );
+ for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it )
+ writeColumn( "text", *it );
+ } else if ( line.left( 6 ) == "BgMode" ) {
+ QString mode = line.section( "//", 0, 0 ).section("\"", 1, 1 );
+ cleanString( & mode );
+ writeString( "backgroundMode", mode ); //###FIX: QWidget:::
+ } else if ( line.left( 10 ) == "BgPalColor" ) {
+ QString 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 0000000..448e850
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QTextStream* input, const QString& name = "dialog" );
+ ~KDEVDLG2UI();
+
+ bool parse();
+ bool parse ( QStringList& get );
+
+ QStringList targetFiles;
+
+protected:
+
+ bool writeDialog( const QString& name );
+
+ QString className;
+ QString line;
+ QTextStream *in;
+ QStringList target;
+
+ void cleanString( QString* text );
+
+ void indent();
+ void undent();
+ void wi();
+
+ void writeClass( const QString& name );
+ void writeCString( const QString& name, const QString& value );
+ void writeString( const QString& name, const QString& value );
+ void writeRect( const QString& name, int x, int y, int w, int h );
+ void writeFont( const QString& family, int pointsize );
+ void writeBool( const QString& name, bool value );
+ void writeNumber( const QString& name, int value );
+ void writeEnum( const QString& name, const QString& value );
+ void writeSet( const QString& name, const QString& value );
+ void writeItem( const QString& name, const QString& value );
+ void writeColumn( const QString& name, const QString& value );
+ void writeColor( const QString& name, const QString& value );
+ void writeStyles( const QStringList styles, bool isFrame );
+ void writeWidgetStart( const QString& qclass );
+ void writeWidgetEnd();
+
+private:
+ int indentation;
+ bool writeToFile;
+ QTextStream* out;
+};
+
+#endif
diff --git a/tools/designer/plugins/kdevdlg/main.cpp b/tools/designer/plugins/kdevdlg/main.cpp
new file mode 100644
index 0000000..1247f3d
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QLibraryInterface
+{
+public:
+ KDevDlgFilter();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface **iface );
+ Q_REFCOUNT;
+
+ QStringList featureList() const;
+ QStringList import( const QString& filter, const QString& filename );
+
+ bool init();
+ void cleanup();
+ bool canUnload() const;
+};
+
+KDevDlgFilter::KDevDlgFilter()
+{
+}
+
+QRESULT KDevDlgFilter::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)(ImportFilterInterface*)this;
+ else if ( uuid == IID_QFeatureList )
+ *iface = (QFeatureListInterface*)this;
+ else if ( uuid == IID_ImportFilter )
+ *iface = (ImportFilterInterface*)this;
+ else if ( uuid == IID_QLibrary )
+ *iface = (QLibraryInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+QStringList KDevDlgFilter::featureList() const
+{
+ QStringList list;
+ list << "KDevelop Dialog Files (*.kdevdlg)" ;
+ return list;
+}
+
+QStringList KDevDlgFilter::import( const QString &, const QString& filename )
+{
+ QFile file( filename );
+ if ( !file.open( IO_ReadOnly ) )
+ qWarning( "uic: Could not open file '%s' ", filename.latin1() );
+ QTextStream in;
+ in.setDevice( &file );
+
+ QString name = filename.right( filename.length() - filename.findRev( QDir::separator() ) - 1 ).section( ".", 0, 0 );
+ KDEVDLG2UI c( &in, name );
+ QStringList 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 0000000..355f5d0
--- /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 0000000..f2e9abb
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QLibraryInterface
+{
+public:
+ RCFilter();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface **iface );
+ Q_REFCOUNT;
+
+ QStringList featureList() const;
+ QStringList import( const QString& filter, const QString& filename );
+
+ bool init();
+ void cleanup();
+ bool canUnload() const;
+};
+
+RCFilter::RCFilter()
+{
+}
+
+QRESULT RCFilter::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)(ImportFilterInterface*)this;
+ else if ( uuid == IID_QFeatureList )
+ *iface = (QFeatureListInterface*)this;
+ else if ( uuid == IID_ImportFilter )
+ *iface = (ImportFilterInterface*)this;
+ else if ( uuid == IID_QLibrary )
+ *iface = (QLibraryInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+QStringList RCFilter::featureList() const
+{
+ QStringList list;
+ list << "Microsoft Resource Files (*.rc)" ;
+ return list;
+}
+
+QStringList RCFilter::import( const QString &, const QString& filename )
+{
+ QFile file( filename );
+ if ( !file.open( IO_ReadOnly ) )
+ qWarning( "uic: Could not open file '%s' ", filename.latin1() );
+ QTextStream in;
+ in.setDevice( &file );
+
+ RC2UI c( &in );
+ QStringList 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 0000000..27ad444
--- /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 0000000..b3e48dd
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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--;
+}
+
+QString RC2UI::stripQM( const QString& string )
+{
+ return string.mid( 1, string.length()-2 );
+}
+
+QStringList RC2UI::splitStyles( const QString& styles, char sep )
+{
+ QString s = styles;
+ QString style;
+ QStringList 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;
+}
+
+QString RC2UI::parseNext( QString& arg, char sep )
+{
+ QString next = arg.left( arg.find(sep) );
+ arg = arg.right( arg.length() - next.length() - 1 );
+ return next;
+}
+
+void RC2UI::writeClass( const QString& name )
+{
+ wi(); *out << "<class>" << name << "</class>" << endl;
+}
+
+void RC2UI::writeCString( const QString& name, const QString& 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 QString& name, const QString& 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 QString& 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 QString& 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 QString& 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 QString& 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 QString& name, const QString& 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 QString& name, const QString& 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 QStringList styles, bool isFrame )
+{
+ if ( isFrame ) {
+ bool defineFrame = FALSE;
+ QString shadow = "NoFrame";
+ QString 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( QTextStream* 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() ) {
+ QString 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( QStringList& get )
+{
+ writeToFile = FALSE;
+ bool result = parse();
+ get = target;
+ return result;
+}
+
+/*!
+ Retrieves a unique name starting with \a start
+*/
+QString RC2UI::useName( const QString& start )
+{
+ QString name = start;
+ int id = 1;
+
+ while ( usedNames.contains( name ) ) {
+ name = start + QString( "%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 {
+ QFile fileOut;
+ QString buffer;
+ int count;
+ QCString className;
+ uint x, y, w, h;
+ uint endDesc;
+ bool space = FALSE;
+ for ( endDesc = 0; endDesc < line.length() ; endDesc++ ) {
+ char c = (QChar)line.at(endDesc);
+ if ( space && (c >= '0') && (c <= '9') )
+ break;
+ space = c==' ';
+ }
+
+ QString 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];
+ QStringList styles;
+ QStringList extendedStyles;
+ QString caption = "";
+ QString baseClass = "";
+ QString widgetType;
+ QString widgetName;
+ QString arguments;
+ int pointsize = 10;
+ QString 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 ( QString(property) == "STYLE" ) {
+ styles = splitStyles(line);
+ if ( styles.contains( "WS_CAPTION" ) )
+ baseClass = "QDialog";
+ else
+ baseClass = "QWidget";
+ } else if ( QString(property) == "CAPTION" ) {
+ caption = stripQM( line );
+ } else if ( QString(property) == "FONT" ) {
+ QString pt = line.left( line.find(",") );
+ pointsize = pt.toInt();
+ fontname = stripQM(line.right( line.length() - line.find(",") - 2 ));
+ }
+ } while ( line != "BEGIN" );
+
+ if ( writeToFile ) {
+
+ QString outputFile = QString(className) + ".ui";
+ fileOut.setName( outputFile );
+ if (!fileOut.open( IO_WriteOnly ) )
+ qFatal( "rc2ui: Could not open output file '%s'", outputFile.latin1() );
+ out = new QTextStream( &fileOut );
+ targetFiles.append( outputFile );
+ } else {
+ out = new QTextStream( &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;
+ QString controlType;
+ QString widgetID;
+ QString 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("QPushButton");
+ 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("QLabel");
+ writeCString( "name", useName("Label_"+widgetID) );
+ writeRect( "geometry", x,y,w,h );
+ writeString( "text", widgetText );
+ QString 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("QCheckBox");
+ 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("QRadioButton");
+ writeCString("name", useName("RadioButton_"+widgetID) );
+ writeRect("geometry", x,y,w,h);
+ writeString("text", widgetText );
+ }
+ break;
+ case IDGroupBox:
+ {
+ isFrame = TRUE;
+ writeClass("QGroupBox");
+ 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("QLineEdit");
+ writeCString( "name", useName("LineEdit_"+widgetID) );
+ } else {
+ writeClass("QMultiLineEdit");
+ writeCString( "name", useName("MultiLineEdit_"+widgetID) );
+ }
+ writeRect( "geometry", x,y,w,h );
+ QString 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("QMultiLineEdit");
+ writeCString("name", useName("MultiLineEdit_"+widgetID) );
+ writeRect("geometry", x,y,w,h );
+ }
+ break;
+ case IDIconView:
+ {
+ isFrame = TRUE;
+ writeClass("QIconView");
+ 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("QListView");
+ 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("QProgressBar");
+ 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("QTabWidget");
+ writeCString("name", useName("TabWidget_"+widgetID) );
+ writeRect("geometry", x,y,w,h );
+ wi(); *out << "<widget>" << endl; indent();
+ writeClass("QWidget");
+ 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("QSpinBox");
+ writeCString("name", useName("SpinBox_"+widgetID) );
+ writeRect("geometry", x,y,w,h);
+ }
+ break;
+ case IDSlider:
+ {
+ writeClass("QSlider");
+ 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("QComboBox");
+ 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("QListBox");
+ 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("QScrollBar");
+ 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("QLabel");
+ writeCString("name", useName("Custom_"+widgetID) );
+ writeRect("geometry", x,y,w,h );
+ writeString("text", "Create a custom widget and place it here." );
+ }
+ default:
+ {
+ writeClass("QLabel");
+ writeCString("name", useName("Unknown_"+widgetID) );
+ writeRect("geometry", x,y,w,h );
+ writeString("text", QString("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;
+
+ QFile fileOut;
+ line = in->readLine();
+ do {
+ char stringtable[256];
+ char discard[12];
+ sscanf( line, "%s %s", stringtable, discard );
+ if ( QString(stringtable) != "STRINGTABLE" )
+ return TRUE;
+ do {
+ line = in->readLine();
+ } while ( line != "BEGIN" );
+
+ QString outputFile = QString(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 QTextStream( &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;
+
+ QString ID;
+ QString value;
+ do {
+ line = in->readLine().stripWhiteSpace();
+ if ( line == "END" )
+ continue;
+
+ ID = parseNext(line, ' ');
+ value = parseNext(line).stripWhiteSpace();
+
+ *out << "static const QString " << 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 0000000..8f3b1c6
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QTextStream* input );
+ ~RC2UI();
+
+ bool parse();
+ bool parse ( QStringList& get );
+
+ QStringList 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();
+
+ QString line;
+ QTextStream *in;
+ QStringList target;
+
+ void indent();
+ void undent();
+
+ QString stripQM( const QString& string );
+ QString parseNext( QString& arg, char sep = ',' );
+ QStringList splitStyles( const QString& styles, char sep = '|' );
+ void wi();
+
+ void writeClass( const QString& name );
+ void writeCString( const QString& name, const QString& value );
+ void writeString( const QString& name, const QString& value );
+ void writeRect( const QString& name, int x, int y, int w, int h );
+ void writeFont( const QString& family, int pointsize );
+ void writeBool( const QString& name, bool value );
+ void writeNumber( const QString& name, int value );
+ void writeEnum( const QString& name, const QString& value );
+ void writeSet( const QString& name, const QString& value );
+
+ void writeStyles( const QStringList styles, bool isFrame );
+private:
+ int indentation;
+ bool writeToFile;
+ QTextStream* out;
+
+ QString useName( const QString& );
+
+ QStringList usedNames;
+
+ const QString blockStart1;
+ const QString blockStart2;
+};
+
+#endif
diff --git a/tools/designer/plugins/wizards/images/qtwizards_menu_1.png b/tools/designer/plugins/wizards/images/qtwizards_menu_1.png
new file mode 100644
index 0000000..9a62ab9
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/qtwizards_menu_1.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/qtwizards_menu_2.png b/tools/designer/plugins/wizards/images/qtwizards_menu_2.png
new file mode 100644
index 0000000..fd52607
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/qtwizards_menu_2.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/qtwizards_menu_3.png b/tools/designer/plugins/wizards/images/qtwizards_menu_3.png
new file mode 100644
index 0000000..7cf15ac
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/qtwizards_menu_3.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/qtwizards_table_1.png b/tools/designer/plugins/wizards/images/qtwizards_table_1.png
new file mode 100644
index 0000000..425b133
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/qtwizards_table_1.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/qtwizards_table_2.png b/tools/designer/plugins/wizards/images/qtwizards_table_2.png
new file mode 100644
index 0000000..f729542
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/qtwizards_table_2.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/qtwizards_table_3.png b/tools/designer/plugins/wizards/images/qtwizards_table_3.png
new file mode 100644
index 0000000..472f267
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/qtwizards_table_3.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/qtwizards_table_4.png b/tools/designer/plugins/wizards/images/qtwizards_table_4.png
new file mode 100644
index 0000000..493b12e
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/qtwizards_table_4.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/re-sort.png b/tools/designer/plugins/wizards/images/re-sort.png
new file mode 100644
index 0000000..43a8234
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/re-sort.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/editcopy.png b/tools/designer/plugins/wizards/images/small/editcopy.png
new file mode 100644
index 0000000..080db08
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/editcopy.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/editcut.png b/tools/designer/plugins/wizards/images/small/editcut.png
new file mode 100644
index 0000000..f8bd744
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/editcut.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/editpaste.png b/tools/designer/plugins/wizards/images/small/editpaste.png
new file mode 100644
index 0000000..dc7915e
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/editpaste.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/filenew.png b/tools/designer/plugins/wizards/images/small/filenew.png
new file mode 100644
index 0000000..4e5a172
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/filenew.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/fileopen.png b/tools/designer/plugins/wizards/images/small/fileopen.png
new file mode 100644
index 0000000..cb18a2c
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/fileopen.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/filesave.png b/tools/designer/plugins/wizards/images/small/filesave.png
new file mode 100644
index 0000000..ad3f6f8
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/filesave.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/print.png b/tools/designer/plugins/wizards/images/small/print.png
new file mode 100644
index 0000000..8a3640b
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/print.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/redo.png b/tools/designer/plugins/wizards/images/small/redo.png
new file mode 100644
index 0000000..3a504a2
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/redo.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/searchfind.png b/tools/designer/plugins/wizards/images/small/searchfind.png
new file mode 100644
index 0000000..900156d
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/searchfind.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/images/small/undo.png b/tools/designer/plugins/wizards/images/small/undo.png
new file mode 100644
index 0000000..2fc8d26
--- /dev/null
+++ b/tools/designer/plugins/wizards/images/small/undo.png
Binary files differ
diff --git a/tools/designer/plugins/wizards/main.cpp b/tools/designer/plugins/wizards/main.cpp
new file mode 100644
index 0000000..617ad65
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QLibraryInterface
+{
+public:
+ StandardTemplateWizardInterface();
+ virtual ~StandardTemplateWizardInterface();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT;
+
+ QStringList featureList() const;
+
+ void setup( const QString &templ, QWidget *widget, DesignerFormWindow *fw, QUnknownInterface *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;
+}
+
+QStringList StandardTemplateWizardInterface::featureList() const
+{
+ QStringList list;
+#ifndef QT_NO_SQL
+ list << "QDataBrowser" << "QDesignerDataBrowser" << "QDataView" << \
+ "QDesignerDataView" << "QDataTable";
+#endif
+ list << "QMainWindow";
+
+ return list;
+}
+
+void StandardTemplateWizardInterface::setup( const QString &templ, QWidget *widget, DesignerFormWindow *fw, QUnknownInterface *aIface )
+{
+ inUse = TRUE;
+#ifndef QT_NO_SQL
+ if ( templ == "QDesignerDataView" ||
+ templ == "QDesignerDataBrowser" ||
+ templ == "QDataView" ||
+ templ == "QDataBrowser" ||
+ templ == "QDataTable" ) {
+ SqlFormWizard wizard( aIface, widget, qApp->mainWidget(), fw, 0, TRUE );
+ wizard.exec();
+ }
+#endif
+ if ( templ == "QMainWindow" ) {
+ MainWindowWizardBase wizard( qApp->mainWidget(), 0, TRUE );
+ wizard.setAppInterface( aIface, fw, widget );
+ wizard.exec();
+ }
+ inUse = FALSE;
+}
+
+QRESULT StandardTemplateWizardInterface::queryInterface( const QUuid& uuid, QUnknownInterface** iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = (QUnknownInterface*)(TemplateWizardInterface*) this;
+ else if ( uuid == IID_QFeatureList )
+ *iface = (QFeatureListInterface*)this;
+ else if ( uuid == IID_TemplateWizard )
+ *iface = (TemplateWizardInterface*)this;
+ else if ( uuid == IID_QLibrary )
+ *iface = (QLibraryInterface*)this;
+ else
+ return QE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return QS_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 0000000..52bc752
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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 QUnknownInterface;</forward>
+<forward>class QWidget;</forward>
+<variable>QWidget *widget;</variable>
+<variable>DesignerInterface *dIface;</variable>
+<variable>DesignerFormWindow *dfw;</variable>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+<widget class="QWizard">
+ <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="QWidget">
+ <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="QLabel" 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="QGroupBox" 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="QCheckBox" 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="QCheckBox" 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="QCheckBox" 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="QLabel" 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="QGroupBox" 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="QCheckBox" 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="QCheckBox" 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="QCheckBox" 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="QLabel" 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="QGroupBox" 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="QLabel" 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="QCheckBox" 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="QCheckBox" 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="QCheckBox" 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="QWidget">
+ <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="QPushButton" 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="QLabel" row="2" column="3">
+ <property name="name">
+ <cstring>TextLabel4_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Toolbar</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>listToolbar</cstring>
+ </property>
+ </widget>
+ <widget class="QPushButton" 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="QListBox" row="3" column="1" rowspan="7" colspan="1">
+ <property name="name">
+ <cstring>listToolbarActions</cstring>
+ </property>
+ </widget>
+ <widget class="QListBox" row="3" column="3" rowspan="7" colspan="1">
+ <property name="name">
+ <cstring>listToolbar</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" 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="QLabel">
+ <property name="name">
+ <cstring>TextLabel5_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Category</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>comboToolbar</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <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="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>TextLabel4_4</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Actions</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>listToolbarActions</cstring>
+ </property>
+ </widget>
+ <widget class="QPushButton" 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="QLabel" 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="QPushButton" 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="QWidget">
+ <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="QLabel" 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="QLabel" 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 QString&amp;)</signal>
+ <receiver>MainWindowWizardBase</receiver>
+ <slot>currentToolbarChanged(const QString&amp;)</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 QString&amp;)</signal>
+ <receiver>MainWindowWizardBase</receiver>
+ <slot>pageSelected(const QString&amp;)</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 QString &amp; s )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">getPixmap( const QString &amp; n, QPixmap &amp; pix )</slot>
+ <slot access="protected" specifier="virtual" language="C++" returnType="void">pageSelected( const QString &amp; )</slot>
+ <slot access="public" specifier="virtual" language="C++" returnType="void">setAppInterface( QUnknownInterface * iface, DesignerFormWindow * fw, QWidget * 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 0000000..8155e62
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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;
+ QString 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;
+ QString 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( QtMsgType, const char * )
+{
+}
+
+void MainWindowWizardBase::accept()
+{
+ if ( !dfw || !dIface || !widget ) {
+ QWizard::accept();
+ return;
+ }
+
+ setFinishEnabled( finishPage, FALSE );
+
+ QPixmap pix;
+
+ QDict<QAction> actions;
+ QPtrList<QAction> usedActions;
+
+ QtMsgHandler oldMsgHandler = qInstallMsgHandler( devNull );
+
+ getPixmap( "filenew", pix );
+
+ QAction *fileNewAction = dfw->createAction( tr( "New" ), pix, tr( "&New" ), CTRL + Key_N, 0, "fileNewAction" );
+ actions.insert( tr( "New" ), fileNewAction );
+ getPixmap( "fileopen", pix );
+ QAction *fileOpenAction = dfw->createAction( tr( "Open" ), pix, tr( "&Open..." ), CTRL + Key_O, 0, "fileOpenAction" );
+ actions.insert( tr( "Open" ), fileOpenAction );
+ getPixmap( "filesave", pix );
+ QAction *fileSaveAction = dfw->createAction( tr( "Save" ), pix, tr( "&Save" ), CTRL + Key_S, 0, "fileSaveAction" );
+ actions.insert( tr( "Save" ), fileSaveAction );
+ QAction *fileSaveAsAction = dfw->createAction( tr( "Save As" ), QIconSet(), tr( "Save &As..." ), 0, 0, "fileSaveAsAction" );
+ actions.insert( tr( "Save As" ), fileSaveAsAction );
+ getPixmap( "print", pix );
+ QAction *filePrintAction = dfw->createAction( tr( "Print" ), pix, tr( "&Print..." ), CTRL + Key_P, 0, "filePrintAction" );
+ actions.insert( tr( "Print" ), filePrintAction );
+ QAction *fileExitAction = dfw->createAction( tr( "Exit" ), QIconSet(), tr( "E&xit" ), 0, 0, "fileExitAction" );
+ actions.insert( tr( "Exit" ), fileExitAction );
+
+ getPixmap( "undo", pix );
+ QAction *editUndoAction = dfw->createAction( tr( "Undo" ), pix, tr( "&Undo" ), CTRL + Key_Z, 0, "editUndoAction" );
+ actions.insert( tr( "Undo" ), editUndoAction );
+ getPixmap( "redo", pix );
+ QAction *editRedoAction = dfw->createAction( tr( "Redo" ), pix, tr( "&Redo" ), CTRL + Key_Y, 0, "editRedoAction" );
+ actions.insert( tr( "Redo" ), editRedoAction );
+ getPixmap( "editcut", pix );
+ QAction *editCutAction = dfw->createAction( tr( "Cut" ), pix, tr( "Cu&t" ), CTRL + Key_X, 0, "editCutAction" );
+ actions.insert( tr( "Cut" ), editCutAction );
+ getPixmap( "editcopy", pix );
+ QAction *editCopyAction = dfw->createAction( tr( "Copy" ), pix, tr( "&Copy" ), CTRL + Key_C, 0, "editCopyAction" );
+ actions.insert( tr( "Copy" ), editCopyAction );
+ getPixmap( "editpaste", pix );
+ QAction *editPasteAction = dfw->createAction( tr( "Paste" ), pix, tr( "&Paste" ), CTRL + Key_V, 0, "editPasteAction" );
+ actions.insert( tr( "Paste" ), editPasteAction );
+ getPixmap( "searchfind", pix );
+ QAction *editFindAction = dfw->createAction( tr( "Find" ), pix, tr( "&Find..." ), CTRL + Key_F, 0, "editFindAction" );
+ actions.insert( tr( "Find" ), editFindAction );
+
+ QAction *helpAboutAction = dfw->createAction( tr( "About" ), QIconSet(), tr( "&About" ), 0, 0, "helpAboutAction" );
+ actions.insert( tr( "About" ), helpAboutAction );
+ QAction *helpContentsAction = dfw->createAction( tr( "Contents" ), QIconSet(), tr( "&Contents..." ), 0, 0, "helpContentsAction" );
+ actions.insert( tr( "Contents" ), helpContentsAction );
+ QAction *helpIndexAction = dfw->createAction( tr( "Index" ), QIconSet(), 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;
+ }
+ QAction *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 ( QAction *ac = usedActions.first(); ac; ac = usedActions.next() ) {
+ if ( QString( ac->name() ).find( "file" ) != -1 && checkCreateConnectionsFile->isChecked() ||
+ QString( ac->name() ).find( "edit" ) != -1 && checkCreateConnectionsEdit->isChecked() ||
+ QString( ac->name() ).find( "help" ) != -1 && checkCreateConnectionsHelp->isChecked() ) {
+ QString 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 );
+
+ QWizard::accept();
+}
+
+void MainWindowWizardBase::currentToolbarChanged( const QString & 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 QString & n, QPixmap & pix )
+{
+ QString name = n + ".png";
+ pix = QPixmap::fromMimeSource( name );
+ DesignerProject *pro = dIface->currentProject();
+ if ( !pro || pro->projectName() == "<No Project>" )
+ return;
+ pro->pixmapCollection()->addPixmap( pix, n, FALSE );
+}
+
+void MainWindowWizardBase::pageSelected( const QString & )
+{
+ if ( currentPage() == toolbarsPage ) {
+ comboToolbar->clear();
+ setupToolbarPage();
+ listToolbarActions->clear();
+ currentToolbarChanged( comboToolbar->text( comboToolbar->currentItem() ) );
+ }
+}
+
+void MainWindowWizardBase::setAppInterface( QUnknownInterface * iface, DesignerFormWindow * fw, QWidget * w )
+{
+ DesignerInterface *d = 0;
+ iface->queryInterface( IID_Designer, (QUnknownInterface**)&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 0000000..c4ee673
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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="QWizard">
+ <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="QWidget">
+ <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="QLabel">
+ <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="QLayoutWidget">
+ <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="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>TextLabel3_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Table:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>listBoxTable</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" 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="QPushButton">
+ <property name="name">
+ <cstring>PushButton5</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel3_3</cstring>
+ </property>
+ <property name="text">
+ <string>Database &amp;Connection:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>listBoxConnection</cstring>
+ </property>
+ </widget>
+ <widget class="QListBox" 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="QListBox" 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="QWidget">
+ <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="QLabel" 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="QLayoutWidget" 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="QPushButton" 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="QPushButton" 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="QPushButton" 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="QListBox" 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="QPushButton" 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="QListBox" 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="QLabel" row="0" column="2">
+ <property name="name">
+ <cstring>TextLabel2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Displayed Fields:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" 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="QWidget">
+ <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="QLabel">
+ <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="QLayoutWidget">
+ <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="QCheckBox">
+ <property name="name">
+ <cstring>checkBoxNavig</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QGroupBox">
+ <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>&amp;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="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkBoxPrev</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkBoxNext</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QCheckBox" row="0" column="1">
+ <property name="name">
+ <cstring>checkBoxFirst</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QCheckBox" row="1" column="1">
+ <property name="name">
+ <cstring>checkBoxLast</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QCheckBox">
+ <property name="name">
+ <cstring>checkBoxEdit</cstring>
+ </property>
+ <property name="text">
+ <string>In&amp;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="QGroupBox">
+ <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>&amp;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="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkBoxInsert</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkBoxUpdate</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QCheckBox" row="0" column="1">
+ <property name="name">
+ <cstring>checkBoxDelete</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QWidget">
+ <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="QLabel" 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="QGroupBox" 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="QCheckBox">
+ <property name="name">
+ <cstring>checkBoxReadOnly</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QGroupBox">
+ <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="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkBoxConfirmInserts</cstring>
+ </property>
+ <property name="text">
+ <string>Confirm &amp;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="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkBoxConfirmUpdates</cstring>
+ </property>
+ <property name="text">
+ <string>Confirm &amp;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="QCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>checkBoxConfirmCancels</cstring>
+ </property>
+ <property name="text">
+ <string>Confirm &amp;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="QCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>checkBoxConfirmDeletes</cstring>
+ </property>
+ <property name="text">
+ <string>Confirm &amp;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="QCheckBox" row="2" column="1">
+ <property name="name">
+ <cstring>checkBoxSorting</cstring>
+ </property>
+ <property name="text">
+ <string>Allow column &amp;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="QWidget">
+ <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="QLabel" 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="QLayoutWidget" 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="QLabel">
+ <property name="name">
+ <cstring>TextLabel3_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QLayoutWidget" 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="QLabel">
+ <property name="name">
+ <cstring>TextLabel3_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QLayoutWidget" 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="QLabel">
+ <property name="name">
+ <cstring>TextLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>(a valid WHERE clause, e.g. id &gt; 100)</string>
+ </property>
+ </widget>
+ <widget class="QMultiLineEdit">
+ <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 &gt; 3)
+((version &gt; 3) and (price &gt; 1000)) or (name like "%embed%")</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget" 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="QLabel">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Sort By</string>
+ </property>
+ </widget>
+ <widget class="QListBox">
+ <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="QLayoutWidget" 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="QPushButton">
+ <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="QPushButton">
+ <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="QPushButton">
+ <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="QPushButton">
+ <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="QPushButton">
+ <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="QLayoutWidget" 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="QLabel">
+ <property name="name">
+ <cstring>TextLabel1_4</cstring>
+ </property>
+ <property name="text">
+ <string>Available Fields</string>
+ </property>
+ </widget>
+ <widget class="QListBox">
+ <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="QWidget">
+ <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="QLabel" 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="QButtonGroup" row="1" column="1" rowspan="1" colspan="5">
+ <property name="name">
+ <cstring>ButtonGroup1</cstring>
+ </property>
+ <property name="title">
+ <string>&amp;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="QRadioButton" 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 &amp;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="QLabel" 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="QLabel" 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="QRadioButton" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>radioLabelsTop</cstring>
+ </property>
+ <property name="text">
+ <string>Labels on &amp;top</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Create labels above data entry fields.</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QCheckBox" row="4" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>checkCreateLayouts</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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="QCheckBox" row="3" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>checkCreateButtonLayout</cstring>
+ </property>
+ <property name="text">
+ <string>Create layout for &amp;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="QCheckBox" row="2" column="1" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>checkCreateFieldLayout</cstring>
+ </property>
+ <property name="text">
+ <string>Create layout for &amp;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="QSpinBox" 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="QLabel" 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="QWidget">
+ <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="QLabel" 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="QLabel" 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="QCheckBox" row="1" column="1">
+ <property name="name">
+ <cstring>checkBoxAutoEdit</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;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(QListBoxItem*)</signal>
+ <receiver>SqlFormWizardBase</receiver>
+ <slot>addSortField()</slot>
+ </connection>
+ <connection>
+ <sender>listBoxSortedField</sender>
+ <signal>doubleClicked(QListBoxItem*)</signal>
+ <receiver>SqlFormWizardBase</receiver>
+ <slot>removeSortField()</slot>
+ </connection>
+ <connection>
+ <sender>listBoxSortedField</sender>
+ <signal>rightButtonClicked(QListBoxItem*,const QPoint&amp;)</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 QString&amp;)</signal>
+ <receiver>SqlFormWizardBase</receiver>
+ <slot>connectionSelected(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>listBoxTable</sender>
+ <signal>highlighted(const QString&amp;)</signal>
+ <receiver>SqlFormWizardBase</receiver>
+ <slot>tableSelected(const QString&amp;)</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 QString &amp; )</slot>
+ <slot access="protected">tableSelected( const QString &amp; )</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 0000000..7519877
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QUnknownInterface *aIface, QWidget *w,
+ QWidget* 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<QDataTable*>(widget) ) {
+ setCaption( "Data Table Wizard" );
+ mode = Table;
+ setAppropriate( navigPage, FALSE );
+ setAppropriate( layoutPage, FALSE );
+ checkBoxAutoEdit->setChecked( FALSE );
+ } else if ( ::qt_cast<QDataBrowser*>(widget) ) {
+ setCaption( "Data Browser Wizard" );
+ setAppropriate( tablePropertiesPage, FALSE );
+ mode = Browser;
+ checkBoxAutoEdit->setChecked( TRUE );
+ } else if ( ::qt_cast<QDataView*>(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 QString &c )
+{
+ if ( !appIface )
+ return;
+
+ DesignerProject *proIface = (DesignerProject*)( (DesignerInterface*)appIface )->currentProject();
+ if ( !proIface )
+ return;
+
+ listBoxTable->clear();
+ QPtrList<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 QString & )
+{
+ 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;
+ QPtrList<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)" ) ) {
+ QStringList lst = *d->fields().find( listBoxTable->currentText() );
+ // remove primary index fields, if any
+ listBoxSortField->insertStringList( lst );
+ d->open( FALSE );
+#ifndef QT_NO_SQL
+ QSqlCursor tab( listBoxTable->currentText(), TRUE, d->connection() );
+ QSqlIndex 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;
+ QListBoxItem *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;
+ QListBoxItem *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;
+ QString f = listBoxField->currentText();
+ if ( !f.isEmpty() )
+ listBoxSelectedField->insertItem( f );
+ listBoxField->removeItem( i );
+}
+
+void SqlFormWizard::addSortField()
+{
+ int i = listBoxSortField->currentItem();
+ if ( i == -1 )
+ return;
+ QString f = listBoxSortField->currentText();
+ if ( !f.isEmpty() )
+ listBoxSortedField->insertItem( f + " ASC" );
+}
+
+void SqlFormWizard::reSortSortField()
+{
+ int i = listBoxSortedField->currentItem();
+ if ( i != -1 ) {
+ QString 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;
+ QListBoxItem *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;
+ QListBoxItem *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();
+ QPtrList<DesignerDatabase> databases = proIface->databaseConnections();
+ QStringList 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 QPushButton *create_widget( QWidget *parent, const char *name,
+ const QString &txt, const QRect &r, DesignerFormWindow *fw )
+{
+ QPushButton *pb = (QPushButton*)fw->create( "QPushButton", 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;
+ }
+
+ QString conn = listBoxConnection->currentText();
+ QString table = listBoxTable->currentText();
+ QStringList 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() ) {
+ QStringList lst;
+ for ( uint i = 0; i < listBoxSortedField->count(); ++i )
+ lst << listBoxSortedField->text( i );
+ widget->setProperty( "sort", lst );
+ formWindow->setPropertyChanged( widget, "sort", TRUE );
+ }
+
+ QPtrList<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;
+ }
+ QSqlCursor tab( listBoxTable->currentText(), TRUE, database->connection() );
+ int columns = 2;
+
+ QSqlEditorFactory * f = QSqlEditorFactory::defaultFactory();
+
+ QWidget * editorDummy;
+ QWidget * editor;
+ QLabel * 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() ) {
+ ((QDataBrowser*)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++ ){
+
+ QSqlField* field = tab.field( listBoxSelectedField->text( j ) );
+ if ( !field )
+ continue;
+
+ /* label */
+ QString labelName = field->name();
+ labelName = labelName.mid(0,1).upper() + labelName.mid(1);
+ label = (QLabel*)formWindow->create( "QLabel", widget,
+ QString( "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,
+ QString( QString( 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 ( QString(editor->className()) == "QLineEdit" &&
+ (field->type() == QVariant::Double ||
+ field->type() == QVariant::Int ||
+ field->type() == QVariant::UInt ) ) {
+ /* default right-align numerics */
+ //##
+ ((QLineEdit*)editor)->setAlignment( Qt::AlignRight );
+ formWindow->setPropertyChanged( editor, "alignment", TRUE );
+ }
+ if ( ::qt_cast<QSpinBox*>(editor) ) {
+ ( (QSpinBox*)editor )->setMaxValue( INT_MAX );
+ formWindow->setPropertyChanged( editor, "maxValue", TRUE );
+ }
+ QStringList 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() ) {
+ QPushButton *pb = create_widget( widget, "PushButtonFirst",
+ "|< &First",
+ QRect( 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() ) {
+ QPushButton *pb = create_widget( widget, "PushButtonPrev",
+ "<< &Prev",
+ QRect( 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() ) {
+ QPushButton *pb = create_widget( widget, "PushButtonNext",
+ "&Next >>",
+ QRect( 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() ) {
+ QPushButton *pb = create_widget( widget, "PushButtonLast", "&Last >|",
+ QRect( 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() ) {
+ QPushButton *pb = create_widget( widget, "PushButtonInsert", "&Insert",
+ QRect( 3 * SPACING * currentCol, row+SPACING, SPACING * 3, SPACING ), formWindow );
+ formWindow->addConnection( pb, "clicked()", widget, "insert()" );
+ currentCol++;
+ formWindow->selectWidget( pb );
+ }
+ if ( checkBoxUpdate->isChecked() ) {
+ QPushButton *pb = create_widget( widget, "PushButtonUpdate", "&Update",
+ QRect( 3 * SPACING * currentCol, row+SPACING, SPACING * 3, SPACING ), formWindow );
+ formWindow->addConnection( pb, "clicked()", widget, "update()" );
+ currentCol++;
+ formWindow->selectWidget( pb );
+ }
+ if ( checkBoxDelete->isChecked() ) {
+ QPushButton *pb = create_widget( widget, "PushButtonDelete", "&Delete",
+ QRect( 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:
+ {
+ QDataTable* sqlTable = ((QDataTable*)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 );
+ }
+
+ QMap<QString, QString> columnFields;
+ sqlTable->setNumCols( listBoxSelectedField->count() ); // no need to change property through mdbIface here, since QDataTable doesn't offer that through Designer
+ for( j = 0; j < listBoxSelectedField->count(); j++ ){
+
+ QSqlField* field = tab.field( listBoxSelectedField->text( j ) );
+ if ( !field )
+ continue;
+
+ QString labelName = field->name();
+ labelName = labelName.mid(0,1).upper() + labelName.mid(1);
+
+ ((QTable*)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 0000000..c82a86e
--- /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 Qt 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 Qt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements 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 Qt Commercial licenses may use this file in
+** accordance with the Qt 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( QUnknownInterface *aIface, QWidget *w, QWidget* parent = 0, DesignerFormWindow *fw = 0,
+ const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~SqlFormWizard();
+
+ void accept() const;
+
+protected slots:
+ void connectionSelected( const QString & );
+ void tableSelected( const QString & );
+ 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:
+ QWidget *widget;
+ QUnknownInterface *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 0000000..1e50693
--- /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