summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/tools/designer/plugins/cppeditor
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:17:53 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:17:53 -0500
commitdda8474928bd7276e1fad8fb7a601e7c83ff2bc2 (patch)
tree7f83910598b33b12730035f086df20b5a53ab99c /tqtinterface/qt4/tools/designer/plugins/cppeditor
parent6260b6178868c03aab1644bf93b0ef043654bdb0 (diff)
downloadexperimental-dda8474928bd7276e1fad8fb7a601e7c83ff2bc2.tar.gz
experimental-dda8474928bd7276e1fad8fb7a601e7c83ff2bc2.zip
Added TQt4 HEAD
Diffstat (limited to 'tqtinterface/qt4/tools/designer/plugins/cppeditor')
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/common.cpp111
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/cppbrowser.cpp78
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/cppbrowser.h50
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/cppcompletion.cpp220
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/cppcompletion.h60
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.cpp168
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.h78
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.pro21
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/editorinterfaceimpl.cpp338
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/editorinterfaceimpl.h107
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp249
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/languageinterfaceimpl.h90
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/mainfilesettings.ui211
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/mainfilesettings.ui.h36
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.cpp102
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.h64
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettings.ui347
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettings.ui.h106
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.cpp106
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h62
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.cpp117
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h54
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.cpp550
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.h73
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/yyreg.cpp800
-rw-r--r--tqtinterface/qt4/tools/designer/plugins/cppeditor/yyreg.h88
26 files changed, 4286 insertions, 0 deletions
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/common.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/common.cpp
new file mode 100644
index 0000000..e757fe1
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/common.cpp
@@ -0,0 +1,111 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "editorinterfaceimpl.h"
+#include "languageinterfaceimpl.h"
+#include "preferenceinterfaceimpl.h"
+#include "projectsettingsinterfaceimpl.h"
+#include "sourcetemplateinterfaceimpl.h"
+
+class CommonInterface : public TQComponentInformationInterface
+{
+public:
+ CommonInterface();
+ virtual ~CommonInterface();
+
+ TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** );
+ TQ_REFCOUNT;
+
+ TQString name() const { return "C++"; }
+ TQString description() const { return "C++ Integration"; }
+ TQString version() const { return "0.1"; }
+ TQString author() const { return "Trolltech AS"; }
+
+private:
+ LanguageInterfaceImpl *langIface;
+ PreferenceInterfaceImpl *prefIface;
+ ProjectSettingsInterfaceImpl *proIface;
+ SourceTemplateInterfaceImpl *srcIface;
+
+};
+
+CommonInterface::CommonInterface()
+{
+ langIface = new LanguageInterfaceImpl( this );
+ langIface->addRef();
+ prefIface = new PreferenceInterfaceImpl( this );
+ prefIface->addRef();
+ proIface = new ProjectSettingsInterfaceImpl( this );
+ proIface->addRef();
+ srcIface = new SourceTemplateInterfaceImpl;
+ srcIface->addRef();
+}
+
+CommonInterface::~CommonInterface()
+{
+ langIface->release();
+ prefIface->release();
+ proIface->release();
+ srcIface->release();
+}
+
+TQRESULT CommonInterface::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface )
+{
+ *iface = 0;
+ if ( uuid == IID_TQUnknown )
+ *iface = (TQUnknownInterface*)this;
+ else if ( uuid == IID_TQComponentInformation )
+ *iface = (TQComponentInformationInterface*)this;
+ else if ( uuid == IID_Editor )
+ *iface = new EditorInterfaceImpl;
+ else if ( uuid == IID_Language )
+ *iface = langIface;
+ else if ( uuid == IID_Preference )
+ *iface = prefIface;
+ else if ( uuid == IID_ProjectSettings )
+ *iface = proIface;
+ else if ( uuid == IID_SourceTemplate )
+ *iface = srcIface;
+ else
+ return TQE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return TQS_OK;
+}
+
+
+TQ_EXPORT_COMPONENT()
+{
+ TQ_CREATE_INSTANCE( CommonInterface )
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppbrowser.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppbrowser.cpp
new file mode 100644
index 0000000..00dca68
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppbrowser.cpp
@@ -0,0 +1,78 @@
+/**********************************************************************
+**
+** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "cppbrowser.h"
+#include <private/tqrichtext_p.h>
+#include <tqprocess.h>
+#include <tqmainwindow.h>
+#include <tqstatusbar.h>
+#include <editor.h>
+
+CppEditorBrowser::CppEditorBrowser( Editor *e )
+ : EditorBrowser( e )
+{
+}
+
+void CppEditorBrowser::showHelp( const TQString &w )
+{
+ TQString word( w );
+ if ( word[ 0 ] == 'Q' ) {
+ if ( word[ (int)word.length() - 1 ] == '&' ||
+ word[ (int)word.length() - 1 ] == '*' )
+ word.remove( word.length() - 1, 1 );
+ word = word.lower() + ".html";
+ TQStringList lst;
+ lst << "assistant" << "-file" << word;
+ TQProcess proc( lst );
+ proc.start();
+ return;
+ }
+
+ if ( word.tqfind( '(' ) != -1 ) {
+ TQString txt = "::" + word.left( word.tqfind( '(' ) );
+ TQTextDocument *doc = curEditor->document();
+ TQTextParagraph *p = doc->firstParagraph();
+ while ( p ) {
+ if ( p->string()->toString().tqfind( txt ) != -1 ) {
+ curEditor->setCursorPosition( p->paragId(), 0 );
+ return;
+ }
+ p = p->next();
+ }
+ }
+
+ TQMainWindow *mw = ::tqqt_cast<TQMainWindow*>(curEditor->tqtopLevelWidget());
+ if ( mw )
+ mw->statusBar()->message( tr( "Nothing available for '%1'" ).arg( w ), 1500 );
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppbrowser.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppbrowser.h
new file mode 100644
index 0000000..c906eaf
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppbrowser.h
@@ -0,0 +1,50 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef CPPBROWSER_H
+#define CPPBROWSER_H
+
+#include <browser.h>
+
+class CppEditorBrowser : public EditorBrowser
+{
+ TQ_OBJECT
+
+public:
+ CppEditorBrowser( Editor *e );
+ void showHelp( const TQString &word );
+
+};
+
+#endif
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppcompletion.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppcompletion.cpp
new file mode 100644
index 0000000..46cd56e
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppcompletion.cpp
@@ -0,0 +1,220 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "cppcompletion.h"
+#include <tqobject.h>
+#include <tqmetaobject.h>
+#include <tqobjectlist.h>
+#include <tqregexp.h>
+
+CppEditorCompletion::CppEditorCompletion( Editor *e )
+ : EditorCompletion( e )
+{
+}
+
+bool CppEditorCompletion::doObjectCompletion( const TQString &objName )
+{
+ if ( !ths )
+ return FALSE;
+ TQString object( objName );
+ int i = -1;
+ if ( ( i = object.tqfindRev( "->" ) ) != -1 )
+ object = object.mid( i + 2 );
+ if ( ( i = object.tqfindRev( "." ) ) != -1 )
+ object = object.mid( i + 1 );
+ object = object.simplifyWhiteSpace();
+ TQObject *obj = 0;
+ if ( ths->name() == object || object == "this" ) {
+ obj = ths;
+ } else {
+ obj = ths->child( object );
+ }
+
+ if ( !obj )
+ return FALSE;
+
+ TQValueList<CompletionEntry> lst;
+
+ if ( !obj->childrenListObject().isEmpty() ) {
+ for ( TQObjectListIt cit( obj->childrenListObject() ); cit.current(); ++cit ) {
+ TQString s( cit.current()->name() );
+ if ( s.tqfind( " " ) == -1 && s.tqfind( "qt_" ) == -1 && s.tqfind( "unnamed" ) == -1 ) {
+ CompletionEntry c;
+ c.type = "variable";
+ c.text = s;
+ c.prefix = "";
+ lst << c;
+ }
+ }
+ }
+
+ TQStrList props = obj->tqmetaObject()->propertyNames( TRUE );
+ for ( TQPtrListIterator<char> pit( props ); pit.current(); ++pit ) {
+ TQString f( pit.current() );
+ TQChar c = f[ 0 ];
+ f.remove( (uint)0, 1 );
+ f.prepend( c.upper() );
+ f.prepend( "set" );
+
+ CompletionEntry ce;
+ ce.type = "property";
+ ce.text = f;
+ ce.postfix = "()";
+
+ if ( lst.tqfind( ce ) == lst.end() )
+ lst << ce;
+ }
+
+ TQStrList slts = obj->tqmetaObject()->slotNames( TRUE );
+ for ( TQPtrListIterator<char> sit( slts ); sit.current(); ++sit ) {
+ TQString f( sit.current() );
+ f = f.left( f.tqfind( "(" ) );
+ CompletionEntry c;
+ c.type = "slot";
+ c.text = f;
+ c.postfix = "()";
+ if ( lst.tqfind( c ) == lst.end() )
+ lst << c;
+ }
+
+ if ( lst.isEmpty() )
+ return FALSE;
+
+ showCompletion( lst );
+ return TRUE;
+}
+
+TQValueList<TQStringList> CppEditorCompletion::functionParameters( const TQString &expr, TQChar &separator,
+ TQString &prefix, TQString &postfix )
+{
+ TQ_UNUSED( prefix );
+ TQ_UNUSED( postfix );
+ separator = ',';
+ if ( !ths )
+ return TQValueList<TQStringList>();
+ TQString func;
+ TQString objName;
+ int i = -1;
+
+ i = expr.tqfindRev( "->" );
+ if ( i == -1 )
+ i = expr.tqfindRev( "." );
+ else
+ ++i;
+ if ( i == -1 ) {
+ i = expr.tqfindRev( " " );
+
+ if ( i == -1 )
+ i = expr.tqfindRev( "\t" );
+ else
+ objName = ths->name();
+
+ if ( i == -1 && expr[ 0 ] != ' ' && expr[ 0 ] != '\t' )
+ objName = ths->name();
+ }
+
+ if ( !objName.isEmpty() ) {
+ func = expr.mid( i + 1 );
+ func = func.simplifyWhiteSpace();
+ } else {
+ func = expr.mid( i + 1 );
+ func = func.simplifyWhiteSpace();
+ TQString ex( expr );
+ ex.remove( i, 0xFFFFFF );
+ if ( ex[ (int)ex.length() - 1 ] == '-' )
+ ex.remove( ex.length() - 1, 1 );
+ int j = -1;
+ j = ex.tqfindRev( "->" );
+ if ( j == -1 )
+ j = ex.tqfindRev( "." );
+ else
+ ++j;
+ if ( j == -1 ) {
+ j = ex.tqfindRev( " " );
+
+ if ( j == -1 )
+ j = ex.tqfindRev( "\t" );
+ else
+ objName = ths->name();
+
+ if ( j == -1 )
+ objName = ths->name();
+ }
+ objName = ex.mid( j + 1 );
+ objName = objName.simplifyWhiteSpace();
+ }
+
+ TQObject *obj = 0;
+ if ( ths->name() == objName || objName == "this" ) {
+ obj = ths;
+ } else {
+ obj = ths->child( objName );
+ }
+
+ if ( !obj )
+ return TQValueList<TQStringList>();
+
+ TQStrList slts = obj->tqmetaObject()->slotNames( TRUE );
+ for ( TQPtrListIterator<char> sit( slts ); sit.current(); ++sit ) {
+ TQString f( sit.current() );
+ f = f.left( f.tqfind( "(" ) );
+ if ( f == func ) {
+ f = TQString( sit.current() );
+ f.remove( (uint)0, f.tqfind( "(" ) + 1 );
+ f = f.left( f.tqfind( ")" ) );
+ TQStringList lst = TQStringList::split( ',', f );
+ if ( !lst.isEmpty() ) {
+ TQValueList<TQStringList> l;
+ l << lst;
+ return l;
+ }
+ }
+ }
+
+ const TQMetaProperty *prop =
+ obj->tqmetaObject()->
+ property( obj->tqmetaObject()->tqfindProperty( func[ 3 ].lower() + func.mid( 4 ), TRUE ), TRUE );
+ if ( prop ) {
+ TQValueList<TQStringList> l;
+ l << TQStringList( prop->type() );
+ return l;
+ }
+
+ return TQValueList<TQStringList>();
+}
+
+void CppEditorCompletion::setContext( TQObject *this_ )
+{
+ ths = this_;
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppcompletion.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppcompletion.h
new file mode 100644
index 0000000..09fb134
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppcompletion.h
@@ -0,0 +1,60 @@
+/**********************************************************************
+**
+** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef CPPCOMPLETION_H
+#define CPPCOMPLETION_H
+
+#include <completion.h>
+#include <tqguardedptr.h>
+
+class CppEditorCompletion : public EditorCompletion
+{
+ TQ_OBJECT
+
+public:
+ CppEditorCompletion( Editor *e );
+
+#if defined(TQ_USING)
+ using EditorCompletion::doObjectCompletion;
+#endif
+ bool doObjectCompletion( const TQString &object );
+ TQValueList<TQStringList> functionParameters( const TQString &func, TQChar &, TQString &prefix, TQString &postfix );
+ void setContext( TQObject *this_ );
+
+private:
+ TQGuardedPtr<TQObject> ths;
+
+};
+
+#endif
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.cpp
new file mode 100644
index 0000000..b824959
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.cpp
@@ -0,0 +1,168 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "cppeditor.h"
+#include "syntaxhighliter_cpp.h"
+#include <cindent.h>
+#include "cppcompletion.h"
+#include "cppbrowser.h"
+#include <parenmatcher.h>
+#include <tqsettings.h>
+#include <tqpopupmenu.h>
+#include <tqinputdialog.h>
+#include <designerinterface.h>
+
+CppEditor::CppEditor( const TQString &fn, TQWidget *tqparent, const char *name, DesignerInterface *i )
+ : Editor( fn, tqparent, name ), dIface( i )
+{
+ if ( dIface )
+ dIface->addRef();
+ document()->setPreProcessor( new SyntaxHighlighter_CPP );
+ document()->setIndent( (indent = new CIndent) );
+ completion = new CppEditorCompletion( this );
+ browser = new CppEditorBrowser( this );
+ int j = 0;
+ while ( SyntaxHighlighter_CPP::keywords[ j ] != TQString() )
+ completion->addCompletionEntry( SyntaxHighlighter_CPP::keywords[ j++ ], 0, FALSE );
+ configChanged();
+}
+
+CppEditor::~CppEditor()
+{
+ delete completion;
+ if ( dIface )
+ dIface->release();
+}
+
+void CppEditor::configChanged()
+{
+ TQString path = "/Trolltech/CppEditor/";
+ TQMap<TQString, ConfigStyle> styles = Config::readStyles( path );
+ config()->styles = styles;
+ ( (SyntaxHighlighter_CPP*)document()->preProcessor() )->updateStyles( config()->styles );
+
+ completion->setEnabled( Config::completion( path ) );
+ parenMatcher->setEnabled( Config::parenMatching( path ) );
+ if ( Config::wordWrap( path ) ) {
+ if ( hScrollBarMode() != AlwaysOff ) {
+ document()->setFormatter( new TQTextFormatterBreakInWords );
+ setHScrollBarMode( AlwaysOff );
+ }
+ } else {
+ if ( hScrollBarMode() != AlwaysOn ) {
+ TQTextFormatterBreakWords *f = new TQTextFormatterBreakWords;
+ f->setWrapEnabled( FALSE );
+ document()->setFormatter( f );
+ setHScrollBarMode( AlwaysOn );
+ }
+ }
+
+ setFont( ( (SyntaxHighlighter_CPP*)document()->preProcessor() )->format( 0 )->font() );
+
+ indent->setTabSize( Config::indentTabSize( path ) );
+ indent->setIndentSize( Config::indentIndentSize( path ) );
+ indent->setKeepTabs( Config::indentKeepTabs( path ) );
+ indent->setAutoIndent( Config::indentAutoIndent( path ) );
+ if ( !Config::indentAutoIndent( path ) )
+ document()->setIndent( 0 );
+ else
+ document()->setIndent( indent );
+
+ document()->setTabStops( ( (SyntaxHighlighter_CPP*)document()->preProcessor() )->format( TQTextPreProcessor::Standard )->width( 'x' ) * Config::indentTabSize( path ) );
+
+ Editor::configChanged();
+}
+
+TQPopupMenu *CppEditor::createPopupMenu( const TQPoint &p )
+{
+ TQPopupMenu *m = Editor::createPopupMenu( p );
+ m->insertSeparator();
+ int adddeclid = m->insertItem( tr( "Add Include File (in Declaration)..." ), this, TQT_SLOT( addInclDecl() ) );
+ int addimplid = m->insertItem( tr( "Add Include File (in Implementation)..." ), this, TQT_SLOT( addInclImpl() ) );
+ int addforid = m->insertItem( tr( "Add Forward Declaration..." ), this, TQT_SLOT( addForward() ) );
+ if ( !dIface->currentForm() ) {
+ m->setItemEnabled( adddeclid, FALSE );
+ m->setItemEnabled( addimplid, FALSE );
+ m->setItemEnabled( addforid, FALSE );
+ }
+ return m;
+}
+
+void CppEditor::addInclDecl()
+{
+ if ( !dIface )
+ return;
+ TQString s = TQInputDialog::getText( tr( "Add Include File (In Declaration)" ),
+ tr( "Input this using the format <b>&lt;include.h&gt;</b> or <b>\"include.h\"</b>" ) );
+ if ( s.isEmpty() )
+ return;
+ DesignerFormWindow *form = dIface->currentForm();
+ TQStringList lst = form->declarationIncludes();
+ lst << s;
+ form->setDeclarationIncludes( lst );
+}
+
+void CppEditor::addInclImpl()
+{
+ if ( !dIface )
+ return;
+ TQString s = TQInputDialog::getText( tr( "Add Include File (In Implementation)" ),
+ tr( "Input this using the format <b>&lt;include.h&gt;</b> or <b>\"include.h\"</b>" ) );
+ if ( s.isEmpty() )
+ return;
+ DesignerFormWindow *form = dIface->currentForm();
+ TQStringList lst = form->implementationIncludes();
+ lst << s;
+ form->setImplementationIncludes( lst );
+}
+
+void CppEditor::addForward()
+{
+ if ( !dIface )
+ return;
+ TQString s = TQInputDialog::getText( tr( "Add Forward Declaration" ),
+ tr( "Input this using the format <b>ClassName;</b>" ) );
+ if ( s.isEmpty() )
+ return;
+ DesignerFormWindow *form = dIface->currentForm();
+ TQStringList lst = form->forwardDeclarations();
+ lst << s;
+ form->setForwardDeclarations( lst );
+}
+
+void CppEditor::paste()
+{
+ Editor::paste();
+ emit intervalChanged();
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.h
new file mode 100644
index 0000000..1b4aa62
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.h
@@ -0,0 +1,78 @@
+/**********************************************************************
+**
+** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef CPPEDITOR_H
+#define CPPEDITOR_H
+
+#include <editor.h>
+
+class EditorCompletion;
+class EditorBrowser;
+struct DesignerInterface;
+class CIndent;
+
+class CppEditor : public Editor
+{
+ TQ_OBJECT
+
+public:
+ CppEditor( const TQString &fn, TQWidget *tqparent, 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(TQ_USING)
+ using TQTextEdit::createPopupMenu;
+#endif
+ TQPopupMenu *createPopupMenu( const TQPoint &p );
+
+ void paste();
+
+private Q_SLOTS:
+ void addInclDecl();
+ void addInclImpl();
+ void addForward();
+
+protected:
+ EditorCompletion *completion;
+ EditorBrowser *browser;
+ DesignerInterface *dIface;
+ CIndent *indent;
+
+};
+
+#endif
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.pro b/tqtinterface/qt4/tools/designer/plugins/cppeditor/cppeditor.pro
new file mode 100644
index 0000000..391c1d7
--- /dev/null
+++ b/tqtinterface/qt4/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/tqtinterface/qt4/tools/designer/plugins/cppeditor/editorinterfaceimpl.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/editorinterfaceimpl.cpp
new file mode 100644
index 0000000..736b082
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/editorinterfaceimpl.cpp
@@ -0,0 +1,338 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "editorinterfaceimpl.h"
+#include <viewmanager.h>
+#include "cppeditor.h"
+#include <private/tqrichtext_p.h>
+#include <tqapplication.h>
+#include "completion.h"
+#include <designerinterface.h>
+#include <tqtimer.h>
+
+EditorInterfaceImpl::EditorInterfaceImpl()
+ : EditorInterface(), viewManager( 0 ), dIface( 0 )
+{
+ updateTimer = new TQTimer( this );
+ connect( updateTimer, TQT_SIGNAL( timeout() ),
+ this, TQT_SLOT( update() ) );
+}
+
+EditorInterfaceImpl::~EditorInterfaceImpl()
+{
+ updateTimer->stop();
+ delete (ViewManager*)viewManager;
+ if ( dIface )
+ dIface->release();
+}
+
+TQRESULT EditorInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface )
+{
+ *iface = 0;
+ if ( uuid == IID_TQUnknown )
+ *iface = (TQUnknownInterface*)this;
+ else if ( uuid == IID_Editor )
+ *iface = (EditorInterface*)this;
+ else
+ return TQE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return TQS_OK;
+}
+
+TQWidget *EditorInterfaceImpl::editor( bool readonly,
+ TQWidget *tqparent, TQUnknownInterface *iface )
+{
+ if ( !viewManager ) {
+ ( (EditorInterfaceImpl*)this )->viewManager = new ViewManager( tqparent, 0 );
+ ( (EditorInterfaceImpl*)this )->viewManager->showMarkerWidget( FALSE );
+ if ( iface )
+ iface->queryInterface( IID_Designer, (TQUnknownInterface**) &dIface );
+ CppEditor *e = new CppEditor( TQString(), viewManager, "editor", dIface );
+ e->setEditable( !readonly );
+ e->installEventFilter( this );
+ connect( e, TQT_SIGNAL( intervalChanged() ), this, TQT_SLOT( intervalChanged() ) );
+ TQApplication::sendPostedEvents( viewManager, TQEvent::ChildInserted );
+ }
+ return viewManager->currentView();
+}
+
+void EditorInterfaceImpl::setText( const TQString &txt )
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ CppEditor *e = (CppEditor*)viewManager->currentView();
+ disconnect( e, TQT_SIGNAL( modificationChanged( bool ) ), this, TQT_SLOT( modificationChanged( bool ) ) );
+ e->setText( txt );
+ e->setModified( FALSE );
+ connect( e, TQT_SIGNAL( modificationChanged( bool ) ), this, TQT_SLOT( modificationChanged( bool ) ) );
+}
+
+TQString EditorInterfaceImpl::text() const
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return TQString();
+ TQString txt = ( (CppEditor*)viewManager->currentView() )->text();
+ if ( !txt.isEmpty() && !txt.endsWith("\n") )
+ txt += "\n";
+ return txt;
+}
+
+bool EditorInterfaceImpl::isUndoAvailable() const
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return FALSE;
+ return ( (CppEditor*)viewManager->currentView() )->isUndoAvailable();
+}
+
+bool EditorInterfaceImpl::isRedoAvailable() const
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return FALSE;
+ return ( (CppEditor*)viewManager->currentView() )->isRedoAvailable();
+}
+
+void EditorInterfaceImpl::undo()
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->undo();
+}
+
+void EditorInterfaceImpl::redo()
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->redo();
+}
+
+void EditorInterfaceImpl::cut()
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->cut();
+}
+
+void EditorInterfaceImpl::copy()
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->copy();
+}
+
+void EditorInterfaceImpl::paste()
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->paste();
+}
+
+void EditorInterfaceImpl::selectAll()
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->selectAll();
+}
+
+bool EditorInterfaceImpl::tqfind( const TQString &expr, bool cs, bool wo, bool forward, bool startAtCursor )
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return FALSE;
+ CppEditor *e = (CppEditor*)viewManager->currentView();
+ if ( startAtCursor )
+ return e->tqfind( expr, cs, wo, forward );
+ int dummy = 0;
+ return e->tqfind( expr, cs, wo, forward, &dummy, &dummy );
+}
+
+bool EditorInterfaceImpl::tqreplace( const TQString &tqfind, const TQString &tqreplace, bool cs, bool wo,
+ bool forward, bool startAtCursor, bool tqreplaceAll )
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return FALSE;
+ CppEditor *e = (CppEditor*)viewManager->currentView();
+ bool ok = FALSE;
+ if ( startAtCursor ) {
+ ok = e->tqfind( tqfind, cs, wo, forward );
+ } else {
+ int dummy = 0;
+ ok = e->tqfind( tqfind, cs, wo, forward, &dummy, &dummy );
+ }
+
+ if ( ok ) {
+ e->removeSelectedText();
+ e->insert( tqreplace, FALSE, FALSE );
+ }
+
+ if ( !tqreplaceAll || !ok ) {
+ if ( ok )
+ e->setSelection( e->textCursor()->paragraph()->paragId(),
+ e->textCursor()->index() - tqreplace.length(),
+ e->textCursor()->paragraph()->paragId(),
+ e->textCursor()->index() );
+ return ok;
+ }
+
+ bool ok2 = TRUE;
+ while ( ok2 ) {
+ ok2 = e->tqfind( tqfind, cs, wo, forward );
+ if ( ok2 ) {
+ e->removeSelectedText();
+ e->insert( tqreplace, FALSE, FALSE );
+ }
+ }
+
+ return TRUE;
+}
+
+void EditorInterfaceImpl::gotoLine( int line )
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->setCursorPosition( line, 0 );
+}
+
+void EditorInterfaceImpl::indent()
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->TQTextEdit::indent();
+}
+
+void EditorInterfaceImpl::splitView()
+{
+#if 0
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ TQTextDocument *doc = ( (CppEditor*)viewManager->currentView() )->document();
+ CppEditor *editor = new CppEditor( TQString(), viewManager, "editor" );
+ editor->setDocument( doc );
+#endif
+}
+
+void EditorInterfaceImpl::scrollTo( const TQString &txt, const TQString & )
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->sync();
+ TQTextDocument *doc = ( (CppEditor*)viewManager->currentView() )->document();
+ TQTextParagraph *p = doc->firstParagraph();
+ while ( p ) {
+ if ( p->string()->toString().tqfind( txt ) != -1 ) {
+ ( (CppEditor*)viewManager->currentView() )->setCursorPosition( p->paragId() + 2, 0 );
+ break;
+ }
+ p = p->next();
+ }
+ ( (CppEditor*)viewManager->currentView() )->setFocus();
+}
+
+void EditorInterfaceImpl::setContext( TQObject *this_ )
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->completionManager()->setContext( this_ );
+}
+
+void EditorInterfaceImpl::setError( int line )
+{
+ if ( !viewManager )
+ return;
+ viewManager->setError( line );
+}
+
+void EditorInterfaceImpl::readSettings()
+{
+ if ( !viewManager )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->configChanged();
+}
+
+void EditorInterfaceImpl::modificationChanged( bool m )
+{
+ if ( viewManager && dIface )
+ dIface->setModified( m, viewManager->currentView() );
+}
+
+void EditorInterfaceImpl::setModified( bool m )
+{
+ if ( !viewManager )
+ return;
+ ( (CppEditor*)viewManager->currentView() )->setModified( m );
+}
+
+bool EditorInterfaceImpl::isModified() const
+{
+ if ( !viewManager )
+ return FALSE;
+ return ( (CppEditor*)viewManager->currentView() )->isModified();
+}
+
+bool EditorInterfaceImpl::eventFilter( TQObject *o, TQEvent *e )
+{
+ if ( e->type() == TQEvent::KeyPress )
+ updateTimer->stop();
+ else if ( e->type() == TQEvent::FocusOut )
+ update();
+
+ return TQObject::eventFilter( o, e );
+}
+
+int EditorInterfaceImpl::numLines() const
+{
+ if ( !viewManager || !viewManager->currentView() )
+ return 0;
+ return ( (CppEditor*)viewManager->currentView() )->paragraphs();
+}
+
+void EditorInterfaceImpl::intervalChanged()
+{
+ if ( !dIface )
+ return;
+ updateTimer->start( 2000, TRUE );
+}
+
+void EditorInterfaceImpl::update()
+{
+ if ( !dIface )
+ return;
+ dIface->updateFunctionList();
+}
+
+void EditorInterfaceImpl::onBreakPointChange( TQObject *receiver, const char *slot )
+{
+ if ( !viewManager )
+ return;
+ connect( viewManager, TQT_SIGNAL( markersChanged() ), receiver, slot );
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/editorinterfaceimpl.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/editorinterfaceimpl.h
new file mode 100644
index 0000000..997a99b
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/editorinterfaceimpl.h
@@ -0,0 +1,107 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef EDITORINTERFACEIMPL_H
+#define EDITORINTERFACEIMPL_H
+
+#include <editorinterface.h>
+#include <tqobject.h>
+#include <tqguardedptr.h>
+
+class TQTimer;
+class ViewManager;
+struct DesignerInterface;
+
+class EditorInterfaceImpl : public TQObject, public EditorInterface
+{
+ TQ_OBJECT
+
+public:
+ EditorInterfaceImpl();
+ virtual ~EditorInterfaceImpl();
+
+ TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** );
+ TQ_REFCOUNT;
+
+ TQWidget *editor( bool readonly, TQWidget *tqparent, TQUnknownInterface *designerIface );
+
+ void setText( const TQString &txt );
+ TQString text() const;
+ bool isUndoAvailable() const;
+ bool isRedoAvailable() const;
+ void undo();
+ void redo();
+ void cut();
+ void copy();
+ void paste();
+ void selectAll();
+ bool tqfind( const TQString &expr, bool cs, bool wo, bool forward, bool startAtCursor );
+ bool tqreplace( const TQString &tqfind, const TQString &tqreplace, bool cs, bool wo, bool forward, bool startAtCursor, bool tqreplaceAll );
+ void gotoLine( int line );
+ void indent();
+ void scrollTo( const TQString &txt, const TQString &first );
+ void splitView();
+ void setContext( TQObject *this_ );
+ void readSettings();
+
+ void setError( int line );
+ void setStep( int ) {}
+ void clearStep() {}
+ void setModified( bool m );
+ bool isModified() const;
+ void setMode( Mode ) {}
+
+ int numLines() const;
+ void breakPoints( TQValueList<uint> & ) const {}
+ void setBreakPoints( const TQValueList<uint> & ) {}
+ void onBreakPointChange( TQObject *receiver, const char *slot );
+ void clearStackFrame() {}
+ void setStackFrame( int ) {}
+
+protected:
+ bool eventFilter( TQObject*, TQEvent* );
+
+private Q_SLOTS:
+ void modificationChanged( bool m );
+ void intervalChanged();
+ void update();
+
+private:
+ TQGuardedPtr<ViewManager> viewManager;
+ DesignerInterface *dIface;
+ TQTimer *updateTimer;
+
+};
+
+#endif
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp
new file mode 100644
index 0000000..14489c5
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/languageinterfaceimpl.cpp
@@ -0,0 +1,249 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "languageinterfaceimpl.h"
+#include <tqobject.h>
+#include <designerinterface.h>
+#include <tqfile.h>
+#include "yyreg.h"
+#include <tqmetaobject.h>
+
+LanguageInterfaceImpl::LanguageInterfaceImpl( TQUnknownInterface *outer )
+ : tqparent( outer ), ref( 0 )
+{
+}
+
+ulong LanguageInterfaceImpl::addRef()
+{
+ return tqparent ? tqparent->addRef() : ref++;
+}
+
+ulong LanguageInterfaceImpl::release()
+{
+ if ( tqparent )
+ return tqparent->release();
+ if ( !--ref ) {
+ delete this;
+ return 0;
+ }
+ return ref;
+}
+
+TQRESULT LanguageInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface )
+{
+ if ( tqparent )
+ return tqparent->queryInterface( uuid, iface );
+
+ *iface = 0;
+ if ( uuid == IID_TQUnknown )
+ *iface = (TQUnknownInterface*)this;
+ else if ( uuid == IID_Language )
+ *iface = (LanguageInterface*)this;
+ else
+ return TQE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return TQS_OK;
+}
+
+
+class NormalizeObject : public TQObject
+{
+public:
+ NormalizeObject() : TQObject() {}
+ static TQCString normalizeSignalSlot( const char *signalSlot ) { return TQObject::normalizeSignalSlot( signalSlot ); }
+};
+
+void LanguageInterfaceImpl::functions( const TQString &code, TQValueList<Function> *functionMap ) const
+{
+ TQValueList<CppFunction> l;
+ extractCppFunctions( code, &l );
+ for ( TQValueList<CppFunction>::Iterator it = l.begin(); it != l.end(); ++it ) {
+ Function func;
+ func.name = (*it).prototype();
+ func.name.remove( 0, (*it).returnType().length() );
+ if ( func.name.tqfind( "::" ) == -1 )
+ continue;
+ func.name.remove( (uint)0, func.name.tqfind( "::" ) + 2 );
+ func.body = (*it).body();
+ func.returnType = (*it).returnType();
+ func.start = (*it).functionStartLineNum();
+ func.end = (*it).closingBraceLineNum();
+ functionMap->append( func );
+ }
+}
+
+TQString LanguageInterfaceImpl::createFunctionStart( const TQString &className, const TQString &func,
+ const TQString &returnType,
+ const TQString & )
+{
+ return returnType + " " + className + "::" + func;
+}
+
+TQStringList LanguageInterfaceImpl::definitions() const
+{
+ TQStringList lst;
+ lst << "Includes (in Implementation)" << "Includes (in Declaration)" << "Forward Declarations" << "Signals";
+ return lst;
+}
+
+TQStringList LanguageInterfaceImpl::definitionEntries( const TQString &definition, TQUnknownInterface *designerIface ) const
+{
+ DesignerInterface *iface = 0;
+ designerIface->queryInterface( IID_Designer, (TQUnknownInterface**) &iface );
+ if ( !iface )
+ return TQStringList();
+ DesignerFormWindow *fw = iface->currentForm();
+ if ( !fw )
+ return TQStringList();
+ TQStringList lst;
+ if ( definition == "Includes (in Implementation)" ) {
+ lst = fw->implementationIncludes();
+ } else if ( definition == "Includes (in Declaration)" ) {
+ lst = fw->declarationIncludes();
+ } else if ( definition == "Forward Declarations" ) {
+ lst = fw->forwardDeclarations();
+ } else if ( definition == "Signals" ) {
+ lst = fw->signalList();
+ }
+ iface->release();
+ return lst;
+}
+
+void LanguageInterfaceImpl::setDefinitionEntries( const TQString &definition, const TQStringList &entries, TQUnknownInterface *designerIface )
+{
+ DesignerInterface *iface = 0;
+ designerIface->queryInterface( IID_Designer, (TQUnknownInterface**) &iface );
+ if ( !iface )
+ return;
+ DesignerFormWindow *fw = iface->currentForm();
+ if ( !fw )
+ return;
+ if ( definition == "Includes (in Implementation)" ) {
+ fw->setImplementationIncludes( entries );
+ } else if ( definition == "Includes (in Declaration)" ) {
+ fw->setDeclarationIncludes( entries );
+ } else if ( definition == "Forward Declarations" ) {
+ fw->setForwardDeclarations( entries );
+ } else if ( definition == "Signals" ) {
+ fw->setSignalList( entries );
+ }
+ iface->release();
+}
+
+TQString LanguageInterfaceImpl::createEmptyFunction()
+{
+ return "{\n\n}\n";
+}
+
+bool LanguageInterfaceImpl::supports( Support s ) const
+{
+ if ( s == ReturnType )
+ return TRUE;
+ if ( s == ConnectionsToCustomSlots )
+ return TRUE;
+ return FALSE;
+}
+
+TQStringList LanguageInterfaceImpl::fileFilterList() const
+{
+ TQStringList f;
+ f << "C++ Files (*.cpp *.C *.cxx *.c++ *.c *.h *.H *.hpp *.hxx)";
+ return f;
+
+}
+TQStringList LanguageInterfaceImpl::fileExtensionList() const
+{
+ TQStringList f;
+ f << "cpp" << "C" << "cxx" << "c++" << "c" <<"h" << "H" << "hpp" << "hxx";
+ return f;
+}
+
+TQString LanguageInterfaceImpl::projectKeyForExtension( const TQString &extension ) const
+{
+ // also handle something like foo.ut.cpp
+ TQString ext = extension;
+ int i = ext.tqfindRev('.');
+ if ( i > -1 && i < (int)(ext.length()-1) )
+ ext = ext.mid( i + 1 );
+ if ( ext[ 0 ] == 'c' || ext[ 0 ] == 'C' )
+ return "SOURCES";
+ return "HEADERS";
+}
+
+void LanguageInterfaceImpl::sourceProjectKeys( TQStringList &keys ) const
+{
+ keys << "HEADERS" << "SOURCES";
+}
+
+ class CheckObject : public TQObject
+{
+public:
+ CheckObject() {}
+ bool checkConnectArgs( const char *signal, const char *member ) { return TQObject::checkConnectArgs( signal, 0, member ); }
+
+};
+
+bool LanguageInterfaceImpl::canConnect( const TQString &signal, const TQString &slot )
+{
+ CheckObject o;
+ return o.checkConnectArgs( signal.latin1(), slot.latin1() );
+}
+
+void LanguageInterfaceImpl::loadFormCode( const TQString &, const TQString &filename,
+ TQValueList<Function> &functions,
+ TQStringList &,
+ TQValueList<Connection> & )
+{
+ TQFile f( filename );
+ if ( !f.open( IO_ReadOnly ) )
+ return;
+ TQTextStream ts( &f );
+ TQString code( ts.read() );
+ this->functions( code, &functions );
+}
+
+void LanguageInterfaceImpl::preferedExtensions( TQMap<TQString, TQString> &extensionMap ) const
+{
+ extensionMap.insert( "cpp", "C++ Source File" );
+ extensionMap.insert( "h", "C++ Header File" );
+}
+
+TQStrList LanguageInterfaceImpl::signalNames( TQObject *obj ) const
+{
+ TQStrList sigs;
+ sigs = obj->tqmetaObject()->signalNames( TRUE );
+ sigs.remove( "destroyed()" );
+ return sigs;
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/languageinterfaceimpl.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/languageinterfaceimpl.h
new file mode 100644
index 0000000..a998dc6
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/languageinterfaceimpl.h
@@ -0,0 +1,90 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef LANGUAGEINTERFACEIMPL_H
+#define LANGUAGEINTERFACEIMPL_H
+
+#include <languageinterface.h>
+
+class LanguageInterfaceImpl : public LanguageInterface
+{
+public:
+ LanguageInterfaceImpl( TQUnknownInterface *outer = 0 );
+
+ ulong addRef();
+ ulong release();
+
+ TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** );
+
+ void functions( const TQString &code, TQValueList<Function> *funcs ) const;
+ void connections( const TQString &, TQValueList<Connection> * ) const {};
+ TQString createFunctionStart( const TQString &className, const TQString &func,
+ const TQString &returnType, const TQString &access );
+ TQStringList definitions() const;
+ TQStringList definitionEntries( const TQString &definition, TQUnknownInterface *designerIface ) const;
+ void setDefinitionEntries( const TQString &definition, const TQStringList &entries, TQUnknownInterface *designerIface );
+ TQString createArguments( const TQString & ) { return TQString(); }
+ TQString createEmptyFunction();
+ bool supports( Support s ) const;
+ TQStringList fileFilterList() const;
+ TQStringList fileExtensionList() const;
+ void preferedExtensions( TQMap<TQString, TQString> &extensionMap ) const;
+ void sourceProjectKeys( TQStringList &keys ) const;
+ TQString projectKeyForExtension( const TQString &extension ) const;
+ TQString cleanSignature( const TQString &sig ) { return sig; } // #### implement me
+ void loadFormCode( const TQString &, const TQString &,
+ TQValueList<Function> &,
+ TQStringList &,
+ TQValueList<Connection> & );
+ TQString formCodeExtension() const { return ".h"; }
+ bool canConnect( const TQString &signal, const TQString &slot );
+ void compressProject( const TQString &, const TQString &, bool ) {}
+ TQString uncompressProject( const TQString &, const TQString & ) { return TQString(); }
+ TQString aboutText() const { return ""; }
+
+ void addConnection( const TQString &, const TQString &,
+ const TQString &, const TQString &,
+ TQString * ) {}
+ void removeConnection( const TQString &, const TQString &,
+ const TQString &, const TQString &,
+ TQString * ) {}
+ TQStrList signalNames( TQObject *obj ) const;
+
+private:
+ TQUnknownInterface *tqparent;
+ ulong ref;
+
+};
+
+#endif
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/mainfilesettings.ui b/tqtinterface/qt4/tools/designer/plugins/cppeditor/mainfilesettings.ui
new file mode 100644
index 0000000..468525f
--- /dev/null
+++ b/tqtinterface/qt4/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="TQDialog">
+ <property name="name">
+ <cstring>CppMainFile</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>308</width>
+ <height>283</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Configure Main-File</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Filename:</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>editFileName</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Main-Form:</string>
+ </property>
+ </widget>
+ <widget class="TQListBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>listForms</cstring>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="3" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonHelp</cstring>
+ </property>
+ <property name="text">
+ <string>Help</string>
+ </property>
+ <property name="accel">
+ <number>4144</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="tqsizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="accel">
+ <number>0</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ <property name="accel">
+ <number>0</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>CppMainFile</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>CppMainFile</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>listForms</sender>
+ <signal>selectionChanged()</signal>
+ <receiver>CppMainFile</receiver>
+ <slot>updateOkButton()</slot>
+ </connection>
+ <connection>
+ <sender>listForms</sender>
+ <signal>currentChanged(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>
+<Q_SLOTS>
+ <slot>init()</slot>
+ <slot>setup( QUnknownInterface * appIface )</slot>
+ <slot>updateOkButton()</slot>
+</Q_SLOTS>
+<pixmapinproject/>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/mainfilesettings.ui.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/mainfilesettings.ui.h
new file mode 100644
index 0000000..9e03dff
--- /dev/null
+++ b/tqtinterface/qt4/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 Q_SLOTS use TQt Designer which will
+** update this file, preserving your code. Create an init() slot in place of
+** a constructor, and a destroy() slot in place of a destructor.
+*****************************************************************************/
+
+#include <designerinterface.h>
+
+void CppMainFile::init()
+{
+}
+
+void CppMainFile::setup( TQUnknownInterface *appIface )
+{
+ DesignerInterface *dIface = 0;
+ appIface->queryInterface( IID_Designer, (TQUnknownInterface**)&dIface );
+ if ( !dIface )
+ return;
+ TQStringList l = dIface->currentProject()->formNames();
+ editFileName->setText( "main.cpp" );
+ listForms->clear();
+ listForms->insertStringList( l );
+ listForms->setCurrentItem( 0 );
+ updateOkButton();
+ editFileName->setFocus();
+ editFileName->selectAll();
+}
+
+void CppMainFile::updateOkButton()
+{
+ buttonOk->setEnabled( editFileName->text().length() > 0 && listForms->currentItem() != -1 );
+}
+
+
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.cpp
new file mode 100644
index 0000000..a9d38e8
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.cpp
@@ -0,0 +1,102 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "preferenceinterfaceimpl.h"
+#include <preferences.h>
+
+PreferenceInterfaceImpl::PreferenceInterfaceImpl( TQUnknownInterface *outer )
+ : tqparent( outer ),
+ ref( 0 ),
+ cppEditorSyntax( 0 )
+{
+}
+
+PreferenceInterfaceImpl::~PreferenceInterfaceImpl()
+{
+}
+
+ulong PreferenceInterfaceImpl::addRef()
+{
+ return tqparent ? tqparent->addRef() : ref++;
+}
+
+ulong PreferenceInterfaceImpl::release()
+{
+ if ( tqparent )
+ return tqparent->release();
+ if ( !--ref ) {
+ delete this;
+ return 0;
+ }
+ return ref;
+}
+
+TQRESULT PreferenceInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface )
+{
+ if ( tqparent )
+ return tqparent->queryInterface( uuid, iface );
+
+ *iface = 0;
+ if ( uuid == IID_TQUnknown )
+ *iface = (TQUnknownInterface*)this;
+ else if ( uuid == IID_Preference )
+ *iface = (PreferenceInterface*)this;
+ else
+ return TQE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return TQS_OK;
+}
+
+PreferenceInterface::Preference *PreferenceInterfaceImpl::preference()
+{
+ if ( !cppEditorSyntax ) {
+ cppEditorSyntax = new PreferencesBase( 0, "cppeditor_syntax" );
+ ( (PreferencesBase*)cppEditorSyntax )->setPath( "/Trolltech/CppEditor/" );
+ cppEditorSyntax->hide();
+ }
+ Preference *pf = 0;
+ pf = new Preference;
+ pf->tab = cppEditorSyntax;
+ pf->title = "C++ Editor";
+ pf->receiver = pf->tab;
+ pf->init_slot = TQT_SLOT( reInit() );
+ pf->accept_slot = TQT_SLOT( save() );
+ return pf;
+}
+
+void PreferenceInterfaceImpl::deletePreferenceObject( Preference *p )
+{
+ delete p;
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.h
new file mode 100644
index 0000000..af2c838
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/preferenceinterfaceimpl.h
@@ -0,0 +1,64 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef PREFERENCEINTERFACEIMPL_H
+#define PREFERENCEINTERFACEIMPL_H
+
+#include <preferenceinterface.h>
+class TQWidget;
+
+class PreferenceInterfaceImpl : public PreferenceInterface
+{
+public:
+ PreferenceInterfaceImpl( TQUnknownInterface *outer = 0 );
+ virtual ~PreferenceInterfaceImpl();
+
+ ulong addRef();
+ ulong release();
+
+ TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** );
+
+ Preference *preference();
+ void connectTo( TQUnknownInterface * ) {}
+ void deletePreferenceObject( Preference * );
+
+private:
+ TQUnknownInterface *tqparent;
+ int ref;
+ TQWidget *cppEditorSyntax;
+
+};
+
+#endif
+
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettings.ui b/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettings.ui
new file mode 100644
index 0000000..b6d8642
--- /dev/null
+++ b/tqtinterface/qt4/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="TQWidget">
+ <property name="name">
+ <cstring>CppProjectSettings</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>373</width>
+ <height>191</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Project Settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Config:</string>
+ </property>
+ </widget>
+ <spacer row="5" column="2">
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="tqsizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="3" column="0">
+ <property name="name">
+ <cstring>TextLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Defines:</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="3" column="2">
+ <property name="name">
+ <cstring>editDefines</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Libs:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="4" column="0">
+ <property name="name">
+ <cstring>TextLabel2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Includepath:</string>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="3" column="1">
+ <item>
+ <property name="text">
+ <string>(all)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>unix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>win32</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>mac</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>comboDefines</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="4" column="1">
+ <item>
+ <property name="text">
+ <string>(all)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>unix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>win32</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>mac</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>comboInclude</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="4" column="2">
+ <property name="name">
+ <cstring>editInclude</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="2" column="2">
+ <property name="name">
+ <cstring>editLibs</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="1" column="2">
+ <property name="name">
+ <cstring>editConfig</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="2" column="1">
+ <item>
+ <property name="text">
+ <string>(all)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>unix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>win32</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>mac</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>comboLibs</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="1" column="1">
+ <item>
+ <property name="text">
+ <string>(all)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>unix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>win32</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>mac</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>comboConfig</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Template:</string>
+ </property>
+ </widget>
+ <spacer row="0" column="2">
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="tqsizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQComboBox" row="0" column="1">
+ <item>
+ <property name="text">
+ <string>app</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>lib</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>comboTemplate</cstring>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection language="C++">
+ <sender>comboConfig</sender>
+ <signal>activated(const 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/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettings.ui.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettings.ui.h
new file mode 100644
index 0000000..72aea91
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettings.ui.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** Add custom slot implementations here. Use a slot init() for
+** initialization code called during construction, and a slot destroy()
+** for cleanup code called during destruction.
+**
+** This file gets modified by TQt Designer whenever you add, rename or
+** remove custom Tslots. Implementation code does not get lost.
+*****************************************************************************/
+
+#include <designerinterface.h>
+
+void CppProjectSettings::reInit( TQUnknownInterface *iface )
+{
+ comboConfig->setCurrentItem( 0 );
+ comboLibs->setCurrentItem( 0 );
+ comboDefines->setCurrentItem( 0 );
+ comboInclude->setCurrentItem( 0 );
+
+ DesignerInterface *dIface = 0;
+ iface->queryInterface( IID_Designer, (TQUnknownInterface**)&dIface );
+ if ( !dIface )
+ return;
+ DesignerProject *project = dIface->currentProject();
+ if ( project->templte() == "app" )
+ comboTemplate->setCurrentItem( 0 );
+ else
+ comboTemplate->setCurrentItem( 1 );
+
+ config.clear();
+ defines.clear();
+ libs.clear();
+ defines.clear();
+ includes.clear();
+
+ const TQString platforms[] = { "(all)", "win32", "unix", "mac", TQString() };
+ for ( int i = 0; platforms[ i ] != TQString(); ++i ) {
+ config.tqreplace( platforms[ i ], project->config( platforms[ i ] ) );
+ libs.tqreplace( platforms[ i ], project->libs( platforms[ i ] ) );
+ defines.tqreplace( platforms[ i ], project->defines( platforms[ i ] ) );
+ includes.tqreplace( platforms[ i ], project->includePath( platforms[ i ] ) );
+ }
+ editConfig->setText( config[ "(all)" ] );
+ editLibs->setText( libs[ "(all)" ] );
+ editDefines->setText( defines[ "(all)" ] );
+ editInclude->setText( includes[ "(all)" ] );
+}
+
+void CppProjectSettings::save( TQUnknownInterface *iface )
+{
+ DesignerInterface *dIface = 0;
+ iface->queryInterface( IID_Designer, (TQUnknownInterface**)&dIface );
+ if ( !dIface )
+ return;
+ DesignerProject *project = dIface->currentProject();
+
+ project->setTemplate( comboTemplate->currentText() );
+ const TQString platforms[] = { "(all)", "win32", "unix", "mac", TQString() };
+ for ( int i = 0; platforms[ i ] != TQString(); ++i ) {
+ project->setConfig( platforms[ i ], config[ platforms[ i ] ] );
+ project->setLibs( platforms[ i ], libs[ platforms[ i ] ] );
+ project->setDefines( platforms[ i ], defines[ platforms[ i ] ] );
+ project->setIncludePath( platforms[ i ], includes[ platforms[ i ] ] );
+ }
+}
+
+void CppProjectSettings::configChanged( const TQString &str )
+{
+ config.tqreplace( comboConfig->currentText(), str );
+}
+
+void CppProjectSettings::libsChanged( const TQString &str )
+{
+ libs.tqreplace( comboLibs->currentText(), str );
+}
+
+void CppProjectSettings::definesChanged( const TQString &str )
+{
+ defines.tqreplace( comboDefines->currentText(), str );
+}
+
+void CppProjectSettings::includesChanged( const TQString &str )
+{
+ includes.tqreplace( comboInclude->currentText(), str );
+}
+
+void CppProjectSettings::configPlatformChanged( const TQString &plat )
+{
+ editConfig->setText( config[ plat ] );
+}
+
+void CppProjectSettings::libsPlatformChanged( const TQString &plat )
+{
+ editLibs->setText( libs[ plat ] );
+}
+
+void CppProjectSettings::definesPlatformChanged( const TQString &plat )
+{
+ editDefines->setText( defines[ plat ] );
+}
+
+void CppProjectSettings::includesPlatformChanged( const TQString &plat )
+{
+ editInclude->setText( includes[ plat ] );
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.cpp
new file mode 100644
index 0000000..279a350
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.cpp
@@ -0,0 +1,106 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "projectsettingsinterfaceimpl.h"
+#include "projectsettings.h"
+
+ProjectSettingsInterfaceImpl::ProjectSettingsInterfaceImpl( TQUnknownInterface *outer )
+ : tqparent( outer ),
+ ref( 0 ),
+ settingsTab( 0 )
+{
+}
+
+ulong ProjectSettingsInterfaceImpl::addRef()
+{
+ return tqparent ? tqparent->addRef() : ref++;
+}
+
+ulong ProjectSettingsInterfaceImpl::release()
+{
+ if ( tqparent )
+ return tqparent->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 = TQT_SLOT( reInit( TQUnknownInterface * ) );
+ pf->accept_slot = TQT_SLOT( save( TQUnknownInterface * ) );
+ return pf;
+}
+
+TQStringList ProjectSettingsInterfaceImpl::projectSettings() const
+{
+ return TQStringList();
+}
+
+void ProjectSettingsInterfaceImpl::connectTo( TQUnknownInterface * )
+{
+}
+
+void ProjectSettingsInterfaceImpl::deleteProjectSettingsObject( ProjectSettings *pf )
+{
+ delete pf;
+}
+
+TQRESULT ProjectSettingsInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface )
+{
+ if ( tqparent )
+ return tqparent->queryInterface( uuid, iface );
+
+ *iface = 0;
+ if ( uuid == IID_TQUnknown )
+ *iface = (TQUnknownInterface*)this;
+ else if ( uuid == IID_ProjectSettings )
+ *iface = (ProjectSettingsInterface*)this;
+ else
+ return TQE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return TQS_OK;
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h
new file mode 100644
index 0000000..5dd0625
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/projectsettingsinterfaceimpl.h
@@ -0,0 +1,62 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef PROJECTSETTINGSINTERFACEIMPL_H
+#define PROJECTSETTINGSINTERFACEIMPL_H
+
+#include <projectsettingsiface.h>
+
+class CppProjectSettings;
+
+class ProjectSettingsInterfaceImpl : public ProjectSettingsInterface
+{
+public:
+ ProjectSettingsInterfaceImpl( TQUnknownInterface *outer = 0 );
+
+ ulong addRef();
+ ulong release();
+
+ ProjectSettings *projectSetting();
+ TQStringList projectSettings() const;
+ void connectTo( TQUnknownInterface *appInterface );
+ void deleteProjectSettingsObject( ProjectSettings * );
+ TQRESULT queryInterface( const TQUuid &uuid, TQUnknownInterface **iface );
+
+private:
+ TQUnknownInterface *tqparent;
+ int ref;
+ CppProjectSettings *settingsTab;
+};
+
+#endif
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.cpp
new file mode 100644
index 0000000..fe84703
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.cpp
@@ -0,0 +1,117 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "sourcetemplateinterfaceimpl.h"
+#include <designerinterface.h>
+#include "mainfilesettings.h"
+#include <tqlineedit.h>
+#include <tqlistbox.h>
+
+SourceTemplateInterfaceImpl::SourceTemplateInterfaceImpl()
+{
+}
+
+TQRESULT SourceTemplateInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_TQUnknown )
+ *iface = (TQUnknownInterface*)this;
+ else if ( uuid == IID_TQFeatureList )
+ *iface = (TQFeatureListInterface*)this;
+ else if ( uuid == IID_SourceTemplate )
+ *iface = (SourceTemplateInterface*)this;
+ else
+ return TQE_NOINTERFACE;
+
+ (*iface)->addRef();
+ return TQS_OK;
+}
+
+TQStringList SourceTemplateInterfaceImpl::featureList() const
+{
+ TQStringList l;
+ l << "C++ Main-File (main.cpp)";
+ return l;
+}
+
+static TQString generateMainCppCode( const TQString &formname, const TQString &include )
+{
+ TQString code;
+ code += "#include <tqapplication.h>\n";
+ code += "#include \"" + include + "\"\n";
+ code += "\n";
+ code += "int main( int argc, char ** argv )\n";
+ code += "{\n";
+ code += " TQApplication a( argc, argv );\n";
+ code += " " + formname + " w;\n";
+ code += " w.show();\n";
+ code += " a.connect( &a, TQT_SIGNAL( lastWindowClosed() ), &a, TQT_SLOT( quit() ) );\n";
+ code += " return a.exec();\n";
+ code += "}\n";
+ return code;
+}
+
+SourceTemplateInterface::Source SourceTemplateInterfaceImpl::create( const TQString &templ,
+ TQUnknownInterface *appIface )
+{
+ SourceTemplateInterface::Source src;
+ src.type = SourceTemplateInterface::Source::Invalid;
+ if ( templ == "C++ Main-File (main.cpp)" ) {
+ CppMainFile dia( 0, 0, TRUE );
+ dia.setup( appIface );
+ if ( dia.exec() == TQDialog::Accepted ) {
+ DesignerInterface *dIface = 0;
+ appIface->queryInterface( IID_Designer, (TQUnknownInterface**)&dIface );
+ if ( dIface ) {
+ src.type = SourceTemplateInterface::Source::FileName;
+ src.filename = dia.editFileName->text();
+ TQString include = dIface->currentProject()->
+ formFileName( dia.listForms->text( dia.listForms->currentItem() ) );
+ include.remove( include.length() - 2, 2 );
+ include += "h";
+ int slashFind = include.tqfindRev('/');
+ if (slashFind != -1)
+ include = include.mid(slashFind+1);
+ src.code = generateMainCppCode( dia.listForms->text( dia.listForms->currentItem() ),
+ include );
+ }
+ }
+ }
+ return src;
+}
+
+TQString SourceTemplateInterfaceImpl::language( const TQString & ) const
+{
+ return "C++";
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h
new file mode 100644
index 0000000..73163dc
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/sourcetemplateinterfaceimpl.h
@@ -0,0 +1,54 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef SOURCETEMPLATEINTERFACEIMPL_H
+#define SOURCETEMPLATEINTERFACEIMPL_H
+
+#include <sourcetemplateiface.h>
+
+class SourceTemplateInterfaceImpl : public SourceTemplateInterface
+{
+public:
+ SourceTemplateInterfaceImpl();
+
+ TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** );
+ TQStringList featureList() const;
+ Source create( const TQString &templ, TQUnknownInterface *appIface );
+ TQString language( const TQString &templ ) const;
+
+ TQ_REFCOUNT
+};
+
+
+#endif
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.cpp
new file mode 100644
index 0000000..251e2b5
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.cpp
@@ -0,0 +1,550 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include "syntaxhighliter_cpp.h"
+#include "paragdata.h"
+#include "tqstring.h"
+#include "tqstringlist.h"
+#include "tqmap.h"
+#include "tqapplication.h"
+#include "tqregexp.h"
+
+const char * const SyntaxHighlighter_CPP::keywords[] = {
+ // C++ keywords
+ "and",
+ "and_eq",
+ "asm",
+ "auto",
+ "bitand",
+ "bitor",
+ "bool",
+ "break",
+ "case",
+ "catch",
+ "char",
+ "class",
+ "compl",
+ "const",
+ "const_cast",
+ "continue",
+ "default",
+ "delete",
+ "do",
+ "double",
+ "dynamic_cast",
+ "else",
+ "enum",
+ "explicit",
+ "export",
+ "extern",
+ "false",
+ "FALSE",
+ "float",
+ "for",
+ "friend",
+ "goto",
+ "if",
+ "inline",
+ "int",
+ "long",
+ "mutable",
+ "namespace",
+ "new",
+ "not",
+ "not_eq",
+ "operator",
+ "or",
+ "or_eq",
+ "private",
+ "protected",
+ "public",
+ "register",
+ "reinterpret_cast",
+ "return",
+ "short",
+ "signed",
+ "sizeof",
+ "static",
+ "static_cast",
+ "struct",
+ "switch",
+ "template",
+ "this",
+ "throw",
+ "true",
+ "TRUE",
+ "try",
+ "typedef",
+ "typeid",
+ "typename",
+ "union",
+ "unsigned",
+ "using",
+ "virtual",
+ "void",
+ "volatile",
+ "wchar_t",
+ "while",
+ "xor",
+ "xor_eq",
+ // additional "keywords" intoduced by TQt
+ "Q_SLOTS",
+ "Q_SIGNALS",
+ "uint",
+ "ushort",
+ "ulong",
+ "emit",
+ // end of array
+ 0
+};
+
+static TQMap<int, TQMap<TQString, int > > *wordMap = 0;
+
+SyntaxHighlighter_CPP::SyntaxHighlighter_CPP()
+ : TQTextPreProcessor(), lastFormat( 0 ), lastFormatId( -1 )
+{
+ TQFont f( tqApp->font() );
+
+ addFormat( Standard, new TQTextFormat( f, TQt::black ) );
+ addFormat( Number, new TQTextFormat( f, TQt::darkBlue ) );
+ addFormat( String, new TQTextFormat( f, TQt::darkGreen ) );
+ addFormat( Type, new TQTextFormat( f, TQt::darkMagenta ) );
+ addFormat( Keyword, new TQTextFormat( f, TQt::darkYellow ) );
+ addFormat( PreProcessor, new TQTextFormat( f, TQt::darkBlue ) );
+ addFormat( Label, new TQTextFormat( f, TQt::darkRed ) );
+ f.setFamily( "times" );
+ addFormat( Comment, new TQTextFormat( f, TQt::red ) );
+
+ if ( wordMap )
+ return;
+
+ wordMap = new TQMap<int, TQMap<TQString, int> >;
+ int len;
+ for ( int i = 0; keywords[ i ]; ++i ) {
+ len = (int)strlen( keywords[ i ] );
+ if ( !wordMap->tqcontains( len ) )
+ wordMap->insert( len, TQMap<TQString, int >() );
+ TQMap<TQString, int> &map = wordMap->operator[]( len );
+ map[ keywords[ i ] ] = Keyword;
+ }
+}
+
+SyntaxHighlighter_CPP::~SyntaxHighlighter_CPP()
+{
+}
+
+static int string2Id( const TQString &s )
+{
+ if ( s == "Standard" )
+ return SyntaxHighlighter_CPP::Standard;
+ if ( s == "Comment" )
+ return SyntaxHighlighter_CPP::Comment;
+ if ( s == "Number" )
+ return SyntaxHighlighter_CPP::Number;
+ if ( s == "String" )
+ return SyntaxHighlighter_CPP::String;
+ if ( s == "Type" )
+ return SyntaxHighlighter_CPP::Type;
+ if ( s == "Preprocessor" )
+ return SyntaxHighlighter_CPP::PreProcessor;
+ if ( s == "Label" )
+ return SyntaxHighlighter_CPP::Label;
+ if ( s == "Keyword" )
+ return SyntaxHighlighter_CPP::Keyword;
+ return SyntaxHighlighter_CPP::Standard;
+}
+
+void SyntaxHighlighter_CPP::updateStyles( const TQMap<TQString, ConfigStyle> &styles )
+{
+ for ( TQMap<TQString, ConfigStyle>::ConstIterator it = styles.begin(); it != styles.end(); ++it ) {
+ int id = string2Id( it.key() );
+ TQTextFormat *f = format( id );
+ if ( !f )
+ continue;
+ f->setFont( (*it).font );
+ f->setColor( (*it).color );
+ }
+}
+
+void SyntaxHighlighter_CPP::process( TQTextDocument *doc, TQTextParagraph *string, int, bool tqinvalidate )
+{
+
+ TQTextFormat *formatStandard = format( Standard );
+ TQTextFormat *formatComment = format( Comment );
+ TQTextFormat *formatNumber = format( Number );
+ TQTextFormat *formatString = format( String );
+ TQTextFormat *formatType = format( Type );
+ TQTextFormat *formatPreProcessor = format( PreProcessor );
+ TQTextFormat *formatLabel = format( Label );
+
+ // states
+ const int StateStandard = 0;
+ const int StateCommentStart1 = 1;
+ const int StateCCommentStart2 = 2;
+ const int StateCppCommentStart2 = 3;
+ const int StateCComment = 4;
+ const int StateCppComment = 5;
+ const int StateCCommentEnd1 = 6;
+ const int StateCCommentEnd2 = 7;
+ const int StateStringStart = 8;
+ const int StateString = 9;
+ const int StateStringEnd = 10;
+ const int StateString2Start = 11;
+ const int StateString2 = 12;
+ const int StateString2End = 13;
+ const int StateNumber = 14;
+ const int StatePreProcessor = 15;
+
+ // tokens
+ const int InputAlpha = 0;
+ const int InputNumber = 1;
+ const int InputAsterix = 2;
+ const int InputSlash = 3;
+ const int InputParen = 4;
+ const int InputSpace = 5;
+ const int InputHash = 6;
+ const int InputQuotation = 7;
+ const int InputApostrophe = 8;
+ const int InputSep = 9;
+
+ static uchar table[ 16 ][ 10 ] = {
+ { StateStandard, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStandard
+ { StateStandard, StateNumber, StateCCommentStart2, StateCppCommentStart2, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCommentStart1
+ { StateCComment, StateCComment, StateCCommentEnd1, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCCommentStart2
+ { StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment }, // CppCommentStart2
+ { StateCComment, StateCComment, StateCCommentEnd1, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCComment
+ { StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment }, // StateCppComment
+ { StateCComment, StateCComment, StateCCommentEnd1, StateCCommentEnd2, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCCommentEnd1
+ { StateStandard, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCCommentEnd2
+ { StateString, StateString, StateString, StateString, StateString, StateString, StateString, StateStringEnd, StateString, StateString }, // StateStringStart
+ { StateString, StateString, StateString, StateString, StateString, StateString, StateString, StateStringEnd, StateString, StateString }, // StateString
+ { StateStandard, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStringEnd
+ { StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2End, StateString2 }, // StateString2Start
+ { StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2End, StateString2 }, // StateString2
+ { StateStandard, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateString2End
+ { StateNumber, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateNumber
+ { StatePreProcessor, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard } // StatePreProcessor
+ };
+
+ TQString buffer;
+
+ int state = StateStandard;
+ if ( string->prev() ) {
+ if ( string->prev()->endState() == -1 )
+ process( doc, string->prev(), 0, FALSE );
+ state = string->prev()->endState();
+ }
+ int input = -1;
+ int i = 0;
+ bool lastWasBackSlash = FALSE;
+ bool makeLastStandard = FALSE;
+
+ ParagData *paragData = (ParagData*)string->extraData();
+ if ( paragData )
+ paragData->parenList.clear();
+ else
+ paragData = new ParagData;
+
+ TQString alphabeth = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPTQRSTUVWXYZ";
+ TQString mathChars = "xXeE";
+ TQString numbers = "0123456789";
+ bool questionMark = FALSE;
+ TQChar lastChar;
+ for (;;) {
+ TQChar c = string->at( i )->c;
+
+ if ( lastWasBackSlash ) {
+ input = InputSep;
+ } else {
+ switch ( c ) {
+ case '*':
+ input = InputAsterix;
+ break;
+ case '/':
+ input = InputSlash;
+ break;
+ case '(': case '[': case '{':
+ input = InputParen;
+ if ( state == StateStandard ||
+ state == StateNumber ||
+ state == StatePreProcessor ||
+ state == StateCCommentEnd2 ||
+ state == StateCCommentEnd1 ||
+ state == StateString2End ||
+ state == StateStringEnd )
+ paragData->parenList << Paren( Paren::Open, c, i );
+ break;
+ case ')': case ']': case '}':
+ input = InputParen;
+ if ( state == StateStandard ||
+ state == StateNumber ||
+ state == StatePreProcessor ||
+ state == StateCCommentEnd2 ||
+ state == StateCCommentEnd1 ||
+ state == StateString2End ||
+ state == StateStringEnd )
+ paragData->parenList << Paren( Paren::Closed, c, i );
+ break;
+ case '#':
+ input = InputHash;
+ break;
+ case '"':
+ input = InputQuotation;
+ break;
+ case '\'':
+ input = InputApostrophe;
+ break;
+ case ' ':
+ input = InputSpace;
+ break;
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9': case '0':
+ if ( alphabeth.tqfind( lastChar ) != -1 &&
+ ( mathChars.tqfind( lastChar ) == -1 || numbers.tqfind( string->at( i - 1 )->c ) == -1 ) ) {
+ input = InputAlpha;
+ } else {
+ if ( input == InputAlpha && numbers.tqfind( lastChar ) != -1 )
+ input = InputAlpha;
+ else
+ input = InputNumber;
+ }
+ break;
+ case ':': {
+ input = InputAlpha;
+ TQChar nextChar = ' ';
+ if ( i < string->length() - 1 )
+ nextChar = string->at( i + 1 )->c;
+ if ( state == StateStandard && !questionMark && lastChar != ':' && nextChar != ':' ) {
+ for ( int j = 0; j < i; ++j ) {
+ if ( string->at( j )->format() == formatStandard )
+ string->setFormat( j, 1, formatLabel, FALSE );
+ }
+ }
+ } break;
+ default: {
+ if ( !questionMark && c == '?' )
+ questionMark = TRUE;
+ if ( c.isLetter() || c == '_' )
+ input = InputAlpha;
+ else
+ input = InputSep;
+ } break;
+ }
+ }
+
+ lastWasBackSlash = !lastWasBackSlash && c == '\\';
+
+ if ( input == InputAlpha )
+ buffer += c;
+
+ state = table[ state ][ input ];
+
+ switch ( state ) {
+ case StateStandard: {
+ int len = buffer.length();
+ string->setFormat( i, 1, formatStandard, FALSE );
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ if ( buffer.length() > 0 && input != InputAlpha ) {
+ if ( buffer[ 0 ] == 'Q' ) {
+ string->setFormat( i - buffer.length(), buffer.length(), formatType, FALSE );
+ } else {
+ TQMap<int, TQMap<TQString, int > >::Iterator it = wordMap->tqfind( len );
+ if ( it != wordMap->end() ) {
+ TQMap<TQString, int >::Iterator it2 = ( *it ).tqfind( buffer );
+ if ( it2 != ( *it ).end() )
+ string->setFormat( i - buffer.length(), buffer.length(), format( ( *it2 ) ), FALSE );
+ }
+ }
+ buffer = TQString();
+ }
+ } break;
+ case StateCommentStart1:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = TRUE;
+ buffer = TQString();
+ break;
+ case StateCCommentStart2:
+ string->setFormat( i - 1, 2, formatComment, FALSE );
+ makeLastStandard = FALSE;
+ buffer = TQString();
+ break;
+ case StateCppCommentStart2:
+ string->setFormat( i - 1, 2, formatComment, FALSE );
+ makeLastStandard = FALSE;
+ buffer = TQString();
+ break;
+ case StateCComment:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatComment, FALSE );
+ buffer = TQString();
+ break;
+ case StateCppComment:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatComment, FALSE );
+ buffer = TQString();
+ break;
+ case StateCCommentEnd1:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatComment, FALSE );
+ buffer = TQString();
+ break;
+ case StateCCommentEnd2:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatComment, FALSE );
+ buffer = TQString();
+ break;
+ case StateStringStart:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatStandard, FALSE );
+ buffer = TQString();
+ break;
+ case StateString:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatString, FALSE );
+ buffer = TQString();
+ break;
+ case StateStringEnd:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatStandard, FALSE );
+ buffer = TQString();
+ break;
+ case StateString2Start:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatStandard, FALSE );
+ buffer = TQString();
+ break;
+ case StateString2:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatString, FALSE );
+ buffer = TQString();
+ break;
+ case StateString2End:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatStandard, FALSE );
+ buffer = TQString();
+ break;
+ case StateNumber:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatNumber, FALSE );
+ buffer = TQString();
+ break;
+ case StatePreProcessor:
+ if ( makeLastStandard )
+ string->setFormat( i - 1, 1, formatStandard, FALSE );
+ makeLastStandard = FALSE;
+ string->setFormat( i, 1, formatPreProcessor, FALSE );
+ buffer = TQString();
+ break;
+ }
+
+ lastChar = c;
+ i++;
+ if ( i >= string->length() )
+ break;
+ }
+
+ string->setExtraData( paragData );
+
+ int oldEndState = string->endState();
+ if ( state == StateCComment ||
+ state == StateCCommentEnd1 ) {
+ string->setEndState( StateCComment );
+ } else if ( state == StateString ) {
+ string->setEndState( StateString );
+ } else if ( state == StateString2 ) {
+ string->setEndState( StateString2 );
+ } else {
+ string->setEndState( StateStandard );
+ }
+
+ string->setFirstPreProcess( FALSE );
+
+ TQTextParagraph *p = string->next();
+ if ( (!!oldEndState || !!string->endState()) && oldEndState != string->endState() &&
+ tqinvalidate && p && !p->firstPreProcess() && p->endState() != -1 ) {
+ while ( p ) {
+ if ( p->endState() == -1 )
+ return;
+ p->setEndState( -1 );
+ p = p->next();
+ }
+ }
+}
+
+TQTextFormat *SyntaxHighlighter_CPP::format( int id )
+{
+ if ( lastFormatId == id && lastFormat )
+ return lastFormat;
+
+ TQTextFormat *f = formats[ id ];
+ lastFormat = f ? f : formats[ 0 ];
+ lastFormatId = id;
+ return lastFormat;
+}
+
+void SyntaxHighlighter_CPP::addFormat( int id, TQTextFormat *f )
+{
+ formats.insert( id, f );
+}
+
+void SyntaxHighlighter_CPP::removeFormat( int id )
+{
+ formats.remove( id );
+}
+
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.h
new file mode 100644
index 0000000..ecaed41
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/syntaxhighliter_cpp.h
@@ -0,0 +1,73 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef TQCPPSYNTAXHIGHLIGHTER_H
+#define TQCPPSYNTAXHIGHLIGHTER_H
+
+#include <private/tqrichtext_p.h>
+#include <conf.h>
+
+class SyntaxHighlighter_CPP : public TQTextPreProcessor
+{
+public:
+ enum CppIds {
+ Comment = 1,
+ Number,
+ String,
+ Type,
+ Keyword,
+ PreProcessor,
+ Label
+ };
+
+ SyntaxHighlighter_CPP();
+ virtual ~SyntaxHighlighter_CPP();
+ void process( TQTextDocument *doc, TQTextParagraph *string, int start, bool tqinvalidate = TRUE );
+ void updateStyles( const TQMap<TQString, ConfigStyle> &styles );
+
+ static const char * const keywords[];
+
+ TQTextFormat *format( int id );
+
+private:
+ void addFormat( int id, TQTextFormat *f );
+ void removeFormat( int id );
+
+ TQTextFormat *lastFormat;
+ int lastFormatId;
+ TQIntDict<TQTextFormat> formats;
+
+};
+
+#endif
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/yyreg.cpp b/tqtinterface/qt4/tools/designer/plugins/cppeditor/yyreg.cpp
new file mode 100644
index 0000000..ab69cce
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/yyreg.cpp
@@ -0,0 +1,800 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#include <tqregexp.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:
+
+ $(TQTDIR)/src/tools/qregexp.cpp
+ $(TQTDIR)/tools/inspector/cppparser.cpp
+
+ You might also want to read Section 2 in the Dragon Book.
+*/
+
+/*
+ Those are the tokens we are interested in. Tok_Something represents
+ any C++ token that does not interest us, but it's dangerous to
+ ignore tokens completely.
+*/
+enum { Tok_Boi, Tok_Ampersand, Tok_Aster, Tok_LeftParen, Tok_RightParen,
+ Tok_Equal, Tok_LeftBrace, Tok_RightBrace, Tok_Semicolon, Tok_Colon,
+ Tok_LeftAngle, Tok_RightAngle, Tok_Comma, Tok_Ellipsis, Tok_Gulbrandsen,
+ Tok_LeftBracket, Tok_RightBracket, Tok_Tilde, Tok_Something, Tok_Comment,
+ Tok_Ident,
+
+ Tok_char, Tok_const, Tok_double, Tok_int, Tok_long, Tok_operator,
+ Tok_short, Tok_signed, Tok_unsigned };
+
+/*
+ The following variables store the lexical analyzer state. The best way
+ to understand them is to implement a function myGetToken() that calls
+ getToken(), to add some qDebug() statements in there and then to
+ #define getToken() myGetToken().
+*/
+static TQString *yyIn; // the input stream
+static int yyPos; // the position of the current token in yyIn
+static int yyCurPos; // the position of the next lookahead character
+static char *yyLexBuf; // the lexeme buffer
+static const int YYLexBufSize = 65536; // big enough for long comments
+static char *yyLex; // the lexeme itself (a pointer into yyLexBuf)
+static int yyCh; // the lookbehind character
+
+/*
+ Moves back to the previous character in the input stream and
+ updates the tokenizer state. This function is to be used only by
+ getToken(), which provides the right abstraction.
+*/
+static inline void readChar()
+{
+ if ( yyCh == EOF )
+ return;
+
+ if ( yyLex > yyLexBuf )
+ *--yyLex = (char) yyCh;
+
+ if ( yyCurPos < 0 )
+ yyCh = EOF;
+ else
+ yyCh = (*yyIn)[yyCurPos].tqunicode();
+ yyCurPos--;
+}
+
+/*
+ Sets up the tokenizer.
+*/
+static void startTokenizer( const TQString& in )
+{
+ yyIn = new TQString;
+ *yyIn = in;
+ yyPos = yyIn->length() - 1;
+ yyCurPos = yyPos;
+ yyLexBuf = new char[YYLexBufSize];
+ yyLex = yyLexBuf + YYLexBufSize - 1;
+ *yyLex = '\0';
+ yyCh = '\0';
+ readChar();
+}
+
+/*
+ Frees resources allocated by the tokenizer.
+*/
+static void stopTokenizer()
+{
+ delete yyIn;
+ delete[] yyLexBuf;
+ yyLexBuf = 0;
+}
+
+/*
+ These two macros implement 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->tqfindRev( TQChar('\n'), yyCurPos ) + 1;
+ TQString line = yyIn->mid( lineStart,
+ yyCurPos - lineStart + 2 );
+ int commentStart = line.tqfind( TQString("//") );
+ if ( commentStart != -1 ) {
+ yyCurPos = lineStart + commentStart - 1;
+ yyPos = yyCurPos + 2;
+ readChar();
+ }
+ }
+ }
+ } else if ( isalnum(yyCh) || yyCh == '_' ) {
+ do {
+ readChar();
+ } while ( isalnum(yyCh) || yyCh == '_' );
+
+ switch ( HASH(yyLex[0], strlen(yyLex)) ) {
+ case HASH( 'c', 4 ):
+ CHECK( "char" );
+ return Tok_char;
+ case HASH( 'c', 5 ):
+ CHECK( "const" );
+ return Tok_const;
+ case HASH( 'd', 6 ):
+ CHECK( "double" );
+ return Tok_double;
+ case HASH( 'i', 3 ):
+ CHECK( "int" );
+ return Tok_int;
+ case HASH( 'l', 4 ):
+ CHECK( "long" );
+ return Tok_long;
+ case HASH( 'o', 8 ):
+ CHECK( "operator" );
+ return Tok_operator;
+ case HASH( 's', 5 ):
+ CHECK( "short" );
+ return Tok_short;
+ case HASH( 's', 6 ):
+ CHECK( "signed" );
+ return Tok_signed;
+ case HASH( 'u', 8 ):
+ CHECK( "unsigned" );
+ return Tok_unsigned;
+ }
+ if ( isdigit(*yyLex) )
+ return Tok_Something;
+ else
+ return Tok_Ident;
+ } else {
+ int quote;
+
+ switch ( yyCh ) {
+ case '!':
+ case '%':
+ case '^':
+ case '+':
+ case '-':
+ case '?':
+ case '|':
+ readChar();
+ return Tok_Something;
+ case '"':
+ case '\'':
+ quote = yyCh;
+ readChar();
+
+ while ( yyCh != EOF && yyCh != '\n' ) {
+ if ( yyCh == quote ) {
+ readChar();
+ if ( yyCh != '\\' )
+ break;
+ } else {
+ readChar();
+ }
+ }
+ return Tok_Something;
+ case '&':
+ readChar();
+ if ( yyCh == '&' ) {
+ readChar();
+ return Tok_Something;
+ } else {
+ return Tok_Ampersand;
+ }
+ case '(':
+ readChar();
+ return Tok_LeftParen;
+ case ')':
+ readChar();
+ return Tok_RightParen;
+ case '*':
+ readChar();
+ return Tok_Aster;
+ case ',':
+ readChar();
+ return Tok_Comma;
+ case '.':
+ readChar();
+ if ( yyCh == '.' ) {
+ do {
+ readChar();
+ } while ( yyCh == '.' );
+ return Tok_Ellipsis;
+ } else {
+ return Tok_Something;
+ }
+ case '/':
+ /*
+ C-style comments are symmetric. C++-style comments
+ are handled elsewhere.
+ */
+ readChar();
+ if ( yyCh == '*' ) {
+ bool metAster = FALSE;
+ bool metAsterSlash = FALSE;
+
+ readChar();
+
+ while ( !metAsterSlash ) {
+ if ( yyCh == EOF )
+ break;
+
+ if ( yyCh == '*' )
+ metAster = TRUE;
+ else if ( metAster && yyCh == '/' )
+ metAsterSlash = TRUE;
+ else
+ metAster = FALSE;
+ readChar();
+ }
+ break;
+ // return Tok_Comment;
+ } else {
+ return Tok_Something;
+ }
+ case ':':
+ readChar();
+ if ( yyCh == ':' ) {
+ readChar();
+ return Tok_Gulbrandsen;
+ } else {
+ return Tok_Colon;
+ }
+ case ';':
+ readChar();
+ return Tok_Semicolon;
+ case '<':
+ readChar();
+ return Tok_LeftAngle;
+ case '=':
+ readChar();
+ return Tok_Equal;
+ case '>':
+ readChar();
+ return Tok_RightAngle;
+ case '[':
+ readChar();
+ return Tok_LeftBracket;
+ case ']':
+ readChar();
+ return Tok_RightBracket;
+ case '{':
+ readChar();
+ return Tok_LeftBrace;
+ case '}':
+ readChar();
+ return Tok_RightBrace;
+ case '~':
+ readChar();
+ return Tok_Tilde;
+ default:
+ readChar();
+ }
+ }
+ }
+ return Tok_Boi;
+}
+
+/*
+ Follow the member function(s) of CppFunction.
+*/
+
+/*
+ Returns the prototype for the C++ function, without the semicolon.
+*/
+TQString CppFunction::prototype() const
+{
+ TQString proto;
+
+ if ( !returnType().isEmpty() )
+ proto = returnType() + TQChar( ' ' );
+ proto += scopedName();
+ proto += TQChar( '(' );
+ if ( !parameterList().isEmpty() ) {
+ TQStringList::ConstIterator p = parameterList().begin();
+ proto += *p;
+ ++p;
+ while ( p != parameterList().end() ) {
+ proto += TQString( ", " );
+ proto += *p;
+ ++p;
+ }
+ }
+ proto += TQChar( ')' );
+ if ( isConst() )
+ proto += TQString( " const" );
+ return proto;
+}
+
+/*
+ The parser follows. We are not really parsing C++, just trying to
+ tqfind the start and end of function definitions.
+
+ One important pitfall is that the parsed code needs not be valid.
+ Parsing from right to left helps cope with that, as explained in
+ comments below.
+
+ In the examples, we will use the symbol @ to stand for the position
+ in the token stream. In "int @ x ;", the lookahead token (yyTok) is
+ 'int'.
+*/
+
+static int yyTok; // the current token
+
+/*
+ Returns TRUE if thingy is a constructor or a destructor; otherwise
+ returns FALSE.
+*/
+static bool isCtorOrDtor( const TQString& thingy )
+{
+ // e.g., Alpha<a>::Beta<Bar<b, c> >::~Beta
+ TQRegExp xtor( TQString(
+ "(?:([A-Z_a-z][0-9A-Z_a-z]*)" // class name
+ "(?:<(?:[^>]|<[^>]*>)*>)*" // template arguments
+ "::)+" // many in a row
+ "~?" // ctor or dtor?
+ "\\1") ); // function has same name as class
+ return xtor.exactMatch( thingy );
+}
+
+/*
+ Skips over any template arguments with balanced angle brackets, and
+ returns the skipped material as a string.
+
+ Before: TQMap < TQString , TQValueList < TQString > > @ m ;
+ After: TQMap @ < TQString , TQValueList < TQString > > m ;
+*/
+static TQString matchTemplateAngles()
+{
+ TQString t;
+
+ if ( yyTok == Tok_RightAngle ) {
+ int depth = 0;
+ do {
+ if ( yyTok == Tok_RightAngle )
+ depth++;
+ else if ( yyTok == Tok_LeftAngle )
+ depth--;
+ t.prepend( yyLex );
+ yyTok = getToken();
+ } while ( depth > 0 && yyTok != Tok_Boi && yyTok != Tok_LeftBrace );
+ }
+ return t;
+}
+
+/*
+ Similar to matchTemplateAngles(), but for array brackets in parameter
+ data types (as in "int *argv[]").
+*/
+static TQString matchArrayBrackets()
+{
+ TQString t;
+
+ while ( yyTok == Tok_RightBracket ) {
+ t.prepend( yyLex );
+ yyTok = getToken();
+ if ( yyTok == Tok_Something ) {
+ t.prepend( yyLex );
+ yyTok = getToken();
+ }
+ if ( yyTok != Tok_LeftBracket )
+ return TQString();
+ t.prepend( yyLex );
+ yyTok = getToken();
+ }
+ return t;
+}
+
+/*
+ Prepends prefix to *type. This operation is in theory trivial, but
+ for the spacing to look good, we have to do something. The original
+ spacing is lost as the input is tokenized.
+*/
+static void prependToType( TQString *type, const TQString& prefix )
+{
+ if ( !type->isEmpty() && !prefix.isEmpty() ) {
+ TQChar left = prefix[(int) prefix.length() - 1];
+ TQChar right = (*type)[0];
+
+ if ( left.isLetter() &&
+ (right.isLetter() || right == TQChar('*') || right == TQChar('&')) )
+ type->prepend( TQChar(' ') );
+ }
+ type->prepend( prefix );
+}
+
+static bool isModifier( int tok )
+{
+ return ( tok == Tok_signed || tok == Tok_unsigned ||
+ tok == Tok_short || tok == Tok_long );
+}
+
+/*
+ Parses a data type (backwards as usual) and returns a textual
+ representation of it.
+*/
+static TQString matchDataType()
+{
+ TQString type;
+
+ while ( yyTok == Tok_Ampersand || yyTok == Tok_Aster ||
+ yyTok == Tok_const ) {
+ prependToType( &type, yyLex );
+ yyTok = getToken();
+ }
+
+ /*
+ This code is really hard to follow... sorry. The loop matches
+ Alpha::Beta::Gamma::...::Omega.
+ */
+ for ( ;; ) {
+ bool modifierMet = FALSE;
+
+ prependToType( &type, matchTemplateAngles() );
+
+ if ( yyTok != Tok_Ident ) {
+ /*
+ People may write 'const unsigned short' or
+ 'short unsigned const' or any other permutation.
+ */
+ while ( yyTok == Tok_const || isModifier(yyTok) ) {
+ prependToType( &type, yyLex );
+ yyTok = getToken();
+ if ( yyTok != Tok_const )
+ modifierMet = TRUE;
+ }
+
+ if ( yyTok == Tok_Tilde ) {
+ prependToType( &type, yyLex );
+ yyTok = getToken();
+ }
+ }
+
+ if ( !modifierMet ) {
+ if ( yyTok == Tok_Ellipsis || yyTok == Tok_Ident ||
+ yyTok == Tok_char || yyTok == Tok_int ||
+ yyTok == Tok_double ) {
+ prependToType( &type, yyLex );
+ yyTok = getToken();
+ } else {
+ return TQString();
+ }
+ } else if ( yyTok == Tok_int || yyTok == Tok_char ||
+ yyTok == Tok_double ) {
+ prependToType( &type, yyLex );
+ yyTok = getToken();
+ }
+
+ while ( yyTok == Tok_const || isModifier(yyTok) ) {
+ prependToType( &type, yyLex );
+ yyTok = getToken();
+ }
+
+ if ( yyTok == Tok_Gulbrandsen ) {
+ prependToType( &type, yyLex );
+ yyTok = getToken();
+ } else {
+ break;
+ }
+ }
+ return type;
+}
+
+/*
+ Parses a function prototype (without the semicolon) and returns an
+ object that stores information about this function.
+*/
+static CppFunction matchFunctionPrototype( bool stripParamNames )
+{
+ CppFunction func;
+#if 0
+ TQString documentation;
+#endif
+ TQString returnType;
+ TQString scopedName;
+ TQStringList params;
+ TQString qualifier;
+ bool cnst = FALSE;
+
+ if ( yyTok == Tok_const ) {
+ cnst = TRUE;
+ yyTok = getToken();
+ }
+
+ if ( yyTok != Tok_RightParen )
+ return func;
+ yyTok = getToken();
+
+ if ( yyTok != Tok_LeftParen ) {
+ for ( ;; ) {
+ TQString brackets = matchArrayBrackets();
+ TQString name;
+ if ( yyTok == Tok_Ident ) {
+ name = yyLex;
+ yyTok = getToken();
+ }
+ TQString type = matchDataType();
+
+ if ( type.isEmpty() ) {
+ if ( name.isEmpty() )
+ return func;
+ type = name;
+ name = TQString();
+ }
+ if ( stripParamNames )
+ name = TQString();
+
+ TQString param = type + TQChar( ' ' ) + name + brackets;
+ params.prepend( param.stripWhiteSpace() );
+
+ if ( yyTok != Tok_Comma )
+ break;
+ yyTok = getToken();
+ }
+ if ( yyTok != Tok_LeftParen )
+ return func;
+ }
+ yyTok = getToken();
+
+ for ( ;; ) {
+ scopedName.prepend( matchTemplateAngles() );
+
+ if ( yyTok != Tok_Ident ) {
+ // the operator keyword should be close
+ int i = 0;
+ while ( i < 4 && yyTok != Tok_operator ) {
+ scopedName.prepend( yyLex );
+ i++;
+ }
+ if ( yyTok != Tok_operator )
+ return func;
+ }
+ scopedName.prepend( yyLex );
+ yyTok = getToken();
+
+ if ( yyTok != Tok_Gulbrandsen )
+ break;
+ scopedName.prepend( yyLex );
+ yyTok = getToken();
+ }
+
+ if ( !isCtorOrDtor(scopedName) ) {
+ returnType = matchDataType();
+ if ( returnType.isEmpty() )
+ return func;
+ }
+
+ /*
+ The documentation feature is unused so far, since we cannot
+ really distinguist between a normal comment between two
+ functions and one that relates to the following function. One
+ good heuristic is to assume that a comment immediately followed
+ by a function with no blank line in between relates to the
+ function, but there's no easy way to tqfind 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 tqfinds bar(). Then it tqfinds "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 TQString& somewhatBody )
+{
+ TQString body = somewhatBody;
+
+ int braceDepth = 0;
+ int i = 0;
+ while ( i < (int) body.length() ) {
+ if ( body[i] == TQChar('{') ) {
+ braceDepth++;
+ } else if ( body[i] == TQChar('}') ) {
+ braceDepth--;
+ if ( braceDepth == 0 ) {
+ body.truncate( i + 1 );
+ break;
+ }
+ }
+ i++;
+ }
+
+ func->setBody( body );
+}
+
+/*
+ Parses a whole C++ file, looking for function definitions. Case in
+ point:
+
+ void foo()
+ {
+ printf( "Hello" );
+
+ void bar()
+ {
+ printf( " world!\n" );
+ }
+
+ The parser looks for left braces and tries to parse a function
+ prototype backwards. First it tqfinds "void bar() {". Then it works
+ up and tqfinds "void foo() {".
+*/
+static void matchTranslationUnit( TQValueList<CppFunction> *flist )
+{
+ int endBody = -1;
+ int startBody;
+
+ for ( ;; ) {
+ if ( endBody == -1 )
+ endBody = yyPos;
+
+ while ( yyTok != Tok_Boi && yyTok != Tok_LeftBrace )
+ yyTok = getToken();
+ if ( yyTok == Tok_Boi )
+ break;
+
+ // found a left brace
+ yyTok = getToken();
+ startBody = yyPos;
+ CppFunction func = matchFunctionPrototype( FALSE );
+ if ( !func.scopedName().isEmpty() ) {
+ TQString body = yyIn->mid( startBody, endBody - startBody );
+ setBody( &func, body );
+ body = func.body(); // setBody() can change the body
+
+ /*
+ Compute important line numbers.
+ */
+ int functionStartLineNo = 1 + TQConstString( yyIn->tqunicode(), yyPos )
+ .string().tqcontains( TQChar('\n') );
+ int startLineNo = functionStartLineNo +
+ TQConstString( yyIn->tqunicode() + yyPos, startBody - yyPos )
+ .string().tqcontains( TQChar('\n') );
+ int endLineNo = startLineNo + body.tqcontains( TQChar('\n') );
+
+ func.setLineNums( functionStartLineNo, startLineNo, endLineNo );
+ flist->prepend( func );
+ endBody = -1;
+ }
+ }
+}
+
+/*
+ Extracts C++ function from source code and put them in a list.
+*/
+void extractCppFunctions( const TQString& code, TQValueList<CppFunction> *flist )
+{
+ startTokenizer( code );
+ yyTok = getToken();
+ matchTranslationUnit( flist );
+ stopTokenizer();
+}
+
+/*
+ Returns the prototype with the parameter names removed.
+*/
+TQString canonicalCppProto( const TQString& proto )
+{
+ startTokenizer( proto );
+ yyTok = getToken();
+ CppFunction func = matchFunctionPrototype( TRUE );
+ stopTokenizer();
+ return func.prototype();
+}
diff --git a/tqtinterface/qt4/tools/designer/plugins/cppeditor/yyreg.h b/tqtinterface/qt4/tools/designer/plugins/cppeditor/yyreg.h
new file mode 100644
index 0000000..ed6bd52
--- /dev/null
+++ b/tqtinterface/qt4/tools/designer/plugins/cppeditor/yyreg.h
@@ -0,0 +1,88 @@
+/**********************************************************************
+**
+** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of TQt Designer.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing 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 TQt Commercial licenses may use this file in
+** accordance with the TQt Commercial License Agreement provided with
+** the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+#ifndef YYREG_H
+#define YYREG_H
+
+#include <tqstringlist.h>
+#include <tqvaluelist.h>
+
+class CppFunction
+{
+public:
+ CppFunction() : cnst( FALSE ), lineno1( 0 ), lineno2( 0 ) { }
+
+ void setReturnType( const TQString& r ) { ret = r; }
+ void setScopedName( const TQString& n ) { nam = n; }
+ void setParameterList( const TQStringList& p ) { params = p; }
+ void setConst( bool c ) { cnst = c; }
+ void setBody( const TQString& b ) { bod = b; }
+ void setDocumentation( const TQString& d ) { doc = d; }
+ void setLineNums( int functionStart, int openingBrace, int closingBrace ) {
+ lineno0 = functionStart;
+ lineno1 = openingBrace;
+ lineno2 = closingBrace;
+ }
+
+ const TQString& returnType() const { return ret; }
+ const TQString& scopedName() const { return nam; }
+ const TQStringList& parameterList() const { return params; }
+ bool isConst() const { return cnst; }
+ TQString prototype() const;
+ const TQString& body() const { return bod; }
+ const TQString& documentation() const { return doc; }
+ int functionStartLineNum() const { return lineno0; }
+ int openingBraceLineNum() const { return lineno1; }
+ int closingBraceLineNum() const { return lineno2; }
+
+#if defined(TQ_FULL_TEMPLATE_INSTANTIATION)
+ bool operator==( const CppFunction& ) const { return FALSE; }
+#endif
+
+private:
+ TQString ret;
+ TQString nam;
+ TQStringList params;
+ bool cnst;
+ TQString bod;
+ TQString doc;
+ int lineno0;
+ int lineno1;
+ int lineno2;
+};
+
+void extractCppFunctions( const TQString& code, TQValueList<CppFunction> *flist );
+TQString canonicalCppProto( const TQString& proto );
+
+#endif