diff options
Diffstat (limited to 'tqtinterface/qt4/tools/designer/designer/metadatabase.cpp')
-rw-r--r-- | tqtinterface/qt4/tools/designer/designer/metadatabase.cpp | 1693 |
1 files changed, 0 insertions, 1693 deletions
diff --git a/tqtinterface/qt4/tools/designer/designer/metadatabase.cpp b/tqtinterface/qt4/tools/designer/designer/metadatabase.cpp deleted file mode 100644 index f428e98..0000000 --- a/tqtinterface/qt4/tools/designer/designer/metadatabase.cpp +++ /dev/null @@ -1,1693 +0,0 @@ -/********************************************************************** -** 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 "metadatabase.h" -#include "widgetfactory.h" -#include "formwindow.h" -#include "parser.h" -#include "widgetdatabase.h" -#include "formfile.h" -#include "propertyobject.h" -#include "project.h" -#include "mainwindow.h" - -#include <tqapplication.h> -#include <tqobject.h> -#include <tqlayout.h> -#include <tqptrdict.h> -#include <tqobjectlist.h> -#include <tqstrlist.h> -#include <tqmetaobject.h> -#include <tqwidgetlist.h> -#include <tqmainwindow.h> -#include <tqregexp.h> -#include <private/tqpluginmanager_p.h> -#include <tqdatetime.h> -#include <tqfile.h> -#include <tqfileinfo.h> -#include <tqtextstream.h> - -#include <stdlib.h> - -class MetaDataBaseRecord -{ -public: - TQObject *object; - TQStringList changedProperties; - TQMap<TQString,TQVariant> fakeProperties; - TQMap<TQString, TQString> propertyComments; - int spacing, margin; - TQString resizeMode; - TQValueList<MetaDataBase::Connection> connections; - TQValueList<MetaDataBase::Function> functionList; - TQValueList<MetaDataBase::Include> includes; - TQValueList<MetaDataBase::Variable> variables; - TQStringList forwards, sigs; - TQWidgetList tabOrder; - MetaDataBase::MetaInfo metaInfo; - TQCursor cursor; - TQMap<int, TQString> pixmapArguments; - TQMap<int, TQString> pixmapKeys; - TQMap<TQString, TQString> columnFields; - TQValueList<uint> breakPoints; - TQMap<int, TQString> breakPointConditions; - TQString exportMacro; -}; - -static TQPtrDict<MetaDataBaseRecord> *db = 0; -static TQPtrList<MetaDataBase::CustomWidget> *cWidgets = 0; -static bool doUpdate = TRUE; -static TQStringList langList; -static TQStringList editorLangList; -static TQPluginManager<LanguageInterface> *languageInterfaceManager = 0; - -/*! - \class MetaDataBase metadatabase.h - \brief Database which stores meta data of widgets - - The MetaDataBase stores meta information of widgets, which are not - stored directly in widgets (properties). This is e.g. the - information which properties have been modified. -*/ - -MetaDataBase::MetaDataBase() -{ -} - -inline void setupDataBase() -{ - if ( !db || !cWidgets ) { - db = new TQPtrDict<MetaDataBaseRecord>( 1481 ); - db->setAutoDelete( TRUE ); - cWidgets = new TQPtrList<MetaDataBase::CustomWidget>; - cWidgets->setAutoDelete( TRUE ); - } -} - -void MetaDataBase::clearDataBase() -{ - delete db; - db = 0; - delete cWidgets; - cWidgets = 0; -} - -void MetaDataBase::addEntry( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return; - setupDataBase(); - if ( db->find( o ) ) - return; - MetaDataBaseRecord *r = new MetaDataBaseRecord; - r->object = TQT_TQOBJECT(o); - r->spacing = r->margin = -1; - db->insert( (void*)o, r ); - - WidgetFactory::initChangedProperties( o ); -} - -void MetaDataBase::removeEntry( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - db->remove( o ); -} - -void MetaDataBase::setPropertyChanged( TQT_BASE_OBJECT_NAME *o, const TQString &property, bool changed ) -{ - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) { - ( (PropertyObject*)o )->mdPropertyChanged( property, changed ); - return; - } - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - if ( changed ) { - if ( r->changedProperties.findIndex( property ) == -1 ) - r->changedProperties.append( property ); - } else { - if ( r->changedProperties.findIndex( property ) != -1 ) - r->changedProperties.remove( property ); - } - - if ( doUpdate && - ( property == "hAlign" || property == "vAlign" || property == "wordwrap" ) ) { - doUpdate = FALSE; - setPropertyChanged( o, "tqalignment", changed || - isPropertyChanged( o, "hAlign" ) || - isPropertyChanged( o, "vAlign" ) || - isPropertyChanged( o, "wordwrap" ) ); - doUpdate = TRUE; - } - - if ( doUpdate && property == "tqalignment" ) { - doUpdate = FALSE; - setPropertyChanged( o, "hAlign", changed ); - setPropertyChanged( o, "vAlign", changed ); - setPropertyChanged( o, "wordwrap", changed ); - doUpdate = TRUE; - } -} - -bool MetaDataBase::isPropertyChanged( TQT_BASE_OBJECT_NAME *o, const TQString &property ) -{ - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) - return ( (PropertyObject*)o )->mdIsPropertyChanged( property ); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return FALSE; - } - - return r->changedProperties.findIndex( property ) != -1; -} - -TQStringList MetaDataBase::changedProperties( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQStringList(); - } - - TQStringList lst( r->changedProperties ); - return lst; -} - -void MetaDataBase::setPropertyComment( TQT_BASE_OBJECT_NAME *o, const TQString &property, const TQString &comment ) -{ - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) { - ( (PropertyObject*)o )->mdSetPropertyComment( property, comment ); - return; - } - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->propertyComments.insert( property, comment ); -} - -TQString MetaDataBase::propertyComment( TQT_BASE_OBJECT_NAME *o, const TQString &property ) -{ - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) - return ( (PropertyObject*)o )->mdPropertyComment( property ); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQString(); - } - - return *r->propertyComments.find( property ); -} - -void MetaDataBase::setFakeProperty( TQT_BASE_OBJECT_NAME *o, const TQString &property, const TQVariant& value ) -{ - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) { - ( (PropertyObject*)o )->mdSetFakeProperty( property, value ); - return; - } - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - r->fakeProperties[property] = value; -} - -TQVariant MetaDataBase::fakeProperty( TQT_BASE_OBJECT_NAME * o, const TQString &property) -{ - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) - return ( (PropertyObject*)o )->mdFakeProperty( property ); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQVariant(); - } - TQMap<TQString, TQVariant>::Iterator it = r->fakeProperties.find( property ); - if ( it != r->fakeProperties.end() ) - return r->fakeProperties[property]; - return WidgetFactory::defaultValue( o, property ); - -} - -TQMap<TQString,TQVariant>* MetaDataBase::fakeProperties( TQT_BASE_OBJECT_NAME* o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return 0; - } - return &r->fakeProperties; -} - -void MetaDataBase::setSpacing( TQT_BASE_OBJECT_NAME *o, int spacing ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r || !o->isWidgetType() ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->spacing = spacing; - TQLayout * tqlayout = 0; - WidgetFactory::layoutType( (TQWidget*)o, tqlayout ); - if ( tqlayout ) { - int spadef = 6; - if ( MainWindow::self->formWindow() ) - spadef = MainWindow::self->formWindow()->layoutDefaultSpacing(); - if ( spacing == -1 ) - tqlayout->setSpacing( spadef ); - else - tqlayout->setSpacing( spacing ); - } -} - -int MetaDataBase::spacing( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return -1; - setupDataBase(); - if ( ::tqqt_cast<TQMainWindow*>(o) ) - o = ( (TQMainWindow*)o )->centralWidget(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r || !o->isWidgetType() ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return -1; - } - - return r->spacing; -} - -void MetaDataBase::setMargin( TQT_BASE_OBJECT_NAME *o, int margin ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r || !o->isWidgetType() ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->margin = margin; - TQLayout * tqlayout = 0; - WidgetFactory::layoutType( (TQWidget*)o, tqlayout ); - - bool isInnerLayout = TRUE; - - TQWidget *widget = (TQWidget*)o; - if ( widget && !::tqqt_cast<TQLayoutWidget*>(widget) && - ( WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( widget ) ) ) || - widget && widget->parentWidget() && ::tqqt_cast<FormWindow*>(widget->parentWidget()) ) ) - isInnerLayout = FALSE; - - - if ( tqlayout ) { - int mardef = 11; - if ( MainWindow::self->formWindow() ) - mardef = MainWindow::self->formWindow()->layoutDefaultMargin(); - if ( margin == -1 ) { - if ( isInnerLayout ) - tqlayout->setMargin( 1 ); - else - tqlayout->setMargin( TQMAX( 1, mardef ) ); - } - else - tqlayout->setMargin( TQMAX( 1, margin ) ); - } -} - -int MetaDataBase::margin( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return -1; - setupDataBase(); - if ( ::tqqt_cast<TQMainWindow*>(o) ) - o = ( (TQMainWindow*)o )->centralWidget(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r || !o->isWidgetType() ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return -1; - } - return r->margin; -} - -void MetaDataBase::setResizeMode( TQT_BASE_OBJECT_NAME *o, const TQString &mode ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r || !o->isWidgetType() ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->resizeMode = mode; -} - -TQString MetaDataBase::resizeMode( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return TQString(); - setupDataBase(); - if ( ::tqqt_cast<TQMainWindow*>(o) ) - o = ( (TQMainWindow*)o )->centralWidget(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r || !o->isWidgetType() ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQString(); - } - return r->resizeMode; -} - -void MetaDataBase::addConnection( TQT_BASE_OBJECT_NAME *o, TQT_BASE_OBJECT_NAME *sender, const TQCString &signal, - TQT_BASE_OBJECT_NAME *receiver, const TQCString &slot, bool addCode ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - if ( !(sender && receiver) ) - return; - Connection conn; - conn.sender = TQT_TQOBJECT(sender); - conn.signal = signal; - conn.receiver = TQT_TQOBJECT(receiver); - conn.slot = slot; - r->connections.append( conn ); - if ( addCode ) { - TQString rec = TQT_TQOBJECT(receiver)->name(); - if ( ::tqqt_cast<FormWindow*>(o) && receiver == ( (FormWindow*)o )->mainContainer() ) - rec = "this"; - TQString sen = TQT_TQOBJECT(sender)->name(); - if ( ::tqqt_cast<FormWindow*>(o) && sender == ( (FormWindow*)o )->mainContainer() ) - sen = "this"; - FormFile *ff = 0; - if ( ::tqqt_cast<FormFile*>(o) ) - ff = (FormFile*)o; - else if ( ::tqqt_cast<FormWindow*>(o) ) - ff = ( (FormWindow*)o )->formFile(); - ff->addConnection( sen, signal, rec, slot ); - } -} - -void MetaDataBase::removeConnection( TQT_BASE_OBJECT_NAME *o, TQObject *sender, const TQCString &signal, - TQObject *receiver, const TQCString &slot ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - if ( !(sender && receiver) ) - return; - for ( TQValueList<Connection>::Iterator it = r->connections.begin(); it != r->connections.end(); ++it ) { - Connection conn = *it; - if ( conn.sender == sender && - conn.signal == signal && - conn.receiver == receiver && - conn.slot == slot ) { - r->connections.remove( it ); - break; - } - } - if ( ::tqqt_cast<FormWindow*>(o) ) { - TQString rec = receiver->name(); - if ( TQT_BASE_OBJECT(receiver) == TQT_BASE_OBJECT(( (FormWindow*)o )->mainContainer()) ) - rec = "this"; - ( (FormWindow*)o )->formFile()->removeConnection( sender->name(), signal, rec, slot ); - } -} - -void MetaDataBase::setupConnections( TQT_BASE_OBJECT_NAME *o, const TQValueList<LanguageInterface::Connection> &conns ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - if ( !::tqqt_cast<FormFile*>(o) ) - return; - - FormFile *formfile = (FormFile*)o; - - r->connections.clear(); - - for ( TQValueList<LanguageInterface::Connection>::ConstIterator cit = conns.begin(); - cit != conns.end(); ++cit ) { - // #### get the correct sender object out of Bla.Blub.sender - TQString senderName = (*cit).sender; - if ( senderName.find( '.' ) != -1 ) - senderName = senderName.mid( senderName.findRev( '.' ) + 1 ); - TQObject *sender = 0; - if ( formfile->formWindow() ) - sender = formfile->formWindow()->child( senderName ); - if ( !sender && formfile->isFake() ) - sender = formfile->project()->objectForFakeFormFile( formfile ); - if ( !sender && senderName == "this" ) - sender = formfile->formWindow() ? - TQT_TQOBJECT(formfile->formWindow()->mainContainer()) : - formfile->project()->objectForFakeFormFile( formfile ); - if ( !sender ) - continue; - MetaDataBase::addConnection( formfile->formWindow() ? - (TQObject*)formfile->formWindow() : - (TQObject*)formfile, - sender, - (*cit).signal.latin1(), - formfile->formWindow() ? - TQT_TQOBJECT(formfile->formWindow()->mainContainer()) : - formfile->project()->objectForFakeFormFile( formfile ), - (*cit).slot.latin1(), - FALSE ); - } -} - -bool MetaDataBase::hasConnection( TQT_BASE_OBJECT_NAME *o, TQT_BASE_OBJECT_NAME *sender, const TQCString &signal, - TQT_BASE_OBJECT_NAME *receiver, const TQCString &slot ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return FALSE; - } - - for ( TQValueList<Connection>::Iterator it = r->connections.begin(); it != r->connections.end(); ++it ) { - Connection conn = *it; - if ( conn.sender == sender && - conn.signal == signal && - conn.receiver == receiver && - conn.slot == slot ) - return TRUE; - } - return FALSE; -} - - -TQValueList<MetaDataBase::Connection> MetaDataBase::connections( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQValueList<Connection>(); - } - return r->connections; -} - -TQValueList<MetaDataBase::Connection> MetaDataBase::connections( TQT_BASE_OBJECT_NAME *o, TQT_BASE_OBJECT_NAME *sender, - TQT_BASE_OBJECT_NAME *receiver ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQValueList<Connection>(); - } - TQValueList<Connection>::Iterator it = r->connections.begin(); - TQValueList<Connection> ret; - TQValueList<Connection>::Iterator conn; - while ( ( conn = it ) != r->connections.end() ) { - ++it; - if ( (*conn).sender == sender && - (*conn).receiver == receiver ) - ret << *conn; - } - - return ret; -} - -TQValueList<MetaDataBase::Connection> MetaDataBase::connections( TQT_BASE_OBJECT_NAME *o, TQT_BASE_OBJECT_NAME *object ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQValueList<Connection>(); - } - TQValueList<Connection>::Iterator it = r->connections.begin(); - TQValueList<Connection> ret; - TQValueList<Connection>::Iterator conn; - while ( ( conn = it ) != r->connections.end() ) { - ++it; - if ( (*conn).sender == object || - (*conn).receiver == object ) - ret << *conn; - } - return ret; -} - -void MetaDataBase::doConnections( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - TQObject *sender = 0, *receiver = 0; - TQObjectList *l = 0; - TQValueList<Connection>::Iterator it = r->connections.begin(); - for ( ; it != r->connections.end(); ++it ) { - Connection conn = *it; - if ( qstrcmp( conn.sender->name(), TQT_TQOBJECT(o)->name() ) == 0 ) { - sender = TQT_TQOBJECT(o); - } else { - l = TQT_TQOBJECT(o)->queryList( 0, conn.sender->name(), FALSE ); - if ( !l || !l->first() ) { - delete l; - continue; - } - sender = l->first(); - delete l; - } - if ( qstrcmp( conn.receiver->name(), TQT_TQOBJECT(o)->name() ) == 0 ) { - receiver = TQT_TQOBJECT(o); - } else { - l = TQT_TQOBJECT(o)->queryList( 0, conn.receiver->name(), FALSE ); - if ( !l || !l->first() ) { - delete l; - continue; - } - receiver = l->first(); - delete l; - } - TQString s = "2""%1"; - s = s.arg( TQString(conn.signal) ); - TQString s2 = "1""%1"; - s2 = s2.arg( TQString(conn.slot) ); - - TQStrList signalList = sender->tqmetaObject()->signalNames( TRUE ); - TQStrList slotList = receiver->tqmetaObject()->slotNames( TRUE ); - - // avoid warnings - if ( signalList.find( conn.signal ) == -1 || - slotList.find( conn.slot ) == -1 ) - continue; - - TQObject::connect( sender, s, receiver, s2 ); - } -} - -bool MetaDataBase::hasSlot( TQT_BASE_OBJECT_NAME *o, const TQCString &slot, bool onlyCustom ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return FALSE; - } - - if ( !onlyCustom ) { - TQStrList slotList = TQT_TQOBJECT(o)->tqmetaObject()->slotNames( TRUE ); - if ( slotList.find( slot ) != -1 ) - return TRUE; - - if ( ::tqqt_cast<FormWindow*>(o) ) { - o = ( (FormWindow*)o )->mainContainer(); - slotList = TQT_TQOBJECT(o)->tqmetaObject()->slotNames( TRUE ); - if ( slotList.find( slot ) != -1 ) - return TRUE; - } - - //if ( ::tqqt_cast<CustomWidget*>(o) ) { - if ( o->inherits( "CustomWidget" ) ) { - MetaDataBase::CustomWidget *w = ( (::CustomWidget*)o )->customWidget(); - for ( TQValueList<Function>::Iterator it = w->lstSlots.begin(); it != w->lstSlots.end(); ++it ) { - TQCString s = (*it).function; - if ( !s.data() ) - continue; - if ( s == slot ) - return TRUE; - } - } - } - - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - Function f = *it; - if ( normalizeFunction( f.function ) == normalizeFunction( slot ) && f.type == "slot" ) - return TRUE; - } - - return FALSE; -} - -bool MetaDataBase::isSlotUsed( TQT_BASE_OBJECT_NAME *o, const TQCString &slot ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return FALSE; - } - - TQValueList<Connection> conns = connections( o ); - for ( TQValueList<Connection>::Iterator it = conns.begin(); it != conns.end(); ++it ) { - if ( (*it).slot == slot ) - return TRUE; - } - return FALSE; -} - - -void MetaDataBase::addFunction( TQT_BASE_OBJECT_NAME *o, const TQCString &function, const TQString &specifier, - const TQString &access, const TQString &type, const TQString &language, - const TQString &returnType ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - Function f; - f.function = function; - f.specifier = specifier; - f.access = access; - f.type = type; - f.language = language; - f.returnType = returnType; - TQValueList<MetaDataBase::Function>::Iterator it = r->functionList.find( f ); - if ( it != r->functionList.end() ) - r->functionList.remove( it ); - r->functionList.append( f ); - ( (FormWindow*)o )->formFile()->addFunctionCode( f ); -} - -void MetaDataBase::setFunctionList( TQT_BASE_OBJECT_NAME *o, const TQValueList<Function> &functionList ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - r->functionList = functionList; -} - -void MetaDataBase::removeFunction( TQT_BASE_OBJECT_NAME *o, const TQCString &function, const TQString &specifier, - const TQString &access, const TQString &type, const TQString &language, - const TQString &returnType ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - if ( MetaDataBase::normalizeFunction( (*it).function ) == - MetaDataBase::normalizeFunction( function ) && - (*it).specifier == specifier && - (*it).access == access && - (*it).type == type && - ( language.isEmpty() || (*it).language == language ) && - ( returnType.isEmpty() || (*it).returnType == returnType ) ) { - ( (FormWindow*)o )->formFile()->removeFunctionCode( *it ); - r->functionList.remove( it ); - break; - } - } -} - -void MetaDataBase::removeFunction( TQT_BASE_OBJECT_NAME *o, const TQString &function ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - if ( normalizeFunction( (*it).function ) == normalizeFunction( function ) ) { - ( (FormWindow*)o )->formFile()->removeFunctionCode( *it ); - r->functionList.remove( it ); - break; - } - } -} - -TQValueList<MetaDataBase::Function> MetaDataBase::functionList( TQT_BASE_OBJECT_NAME *o, bool onlyFunctions ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQValueList<Function>(); - } - if ( !onlyFunctions ) - return r->functionList; - TQValueList<Function> fList; - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - if ( (*it).type == "function" ) - fList.append( *it ); - } - return fList; -} - -TQValueList<MetaDataBase::Function> MetaDataBase::slotList( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQValueList<Function>(); - } - TQValueList<Function> slotList; - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - if ( (*it).type == "slot" ) - slotList.append( *it ); - } - return slotList; -} - -void MetaDataBase::changeFunction( TQT_BASE_OBJECT_NAME *o, const TQString &function, const TQString &newName, - const TQString &returnType ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - Function f = *it; - if ( normalizeFunction( f.function ) == normalizeFunction( function ) ) { - (*it).function = newName; - if ( !returnType.isNull() ) - (*it).returnType = returnType; - return; - } - } -} - -void MetaDataBase::changeFunctionAttributes( TQT_BASE_OBJECT_NAME *o, const TQString &oldName, const TQString &newName, - const TQString &specifier, const TQString &access, - const TQString &type, const TQString &language, - const TQString &returnType ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - Function f = *it; - if ( normalizeFunction( f.function ) == normalizeFunction( oldName ) ) { - (*it).function = newName; - (*it).specifier = specifier; - (*it).access = access; - (*it).type = type; - (*it).language = language; - (*it).returnType = returnType; - return; - } - } -} - -bool MetaDataBase::hasFunction( TQT_BASE_OBJECT_NAME *o, const TQCString &function, bool onlyCustom ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return FALSE; - } - - if ( !onlyCustom ) { - TQStrList functionList = TQT_TQOBJECT(o)->tqmetaObject()->slotNames( TRUE ); - if ( functionList.find( function ) != -1 ) - return TRUE; - - if ( ::tqqt_cast<FormWindow*>(o) ) { - o = ( (FormWindow*)o )->mainContainer(); - functionList = TQT_TQOBJECT(o)->tqmetaObject()->slotNames( TRUE ); - if ( functionList.find( function ) != -1 ) - return TRUE; - } - - //if ( ::tqqt_cast<CustomWidget*>(o) ) { - if ( o->inherits( "CustomWidget" ) ) { - MetaDataBase::CustomWidget *w = ( (::CustomWidget*)o )->customWidget(); - for ( TQValueList<Function>::Iterator it = w->lstSlots.begin(); it != w->lstSlots.end(); ++it ) { - TQCString s = (*it).function; - if ( !s.data() ) - continue; - if ( s == function ) - return TRUE; - } - } - } - - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - Function f = *it; - if ( normalizeFunction( f.function ) == normalizeFunction( function ) ) - return TRUE; - } - - return FALSE; -} - -TQString MetaDataBase::languageOfFunction( TQT_BASE_OBJECT_NAME *o, const TQCString &function ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQString(); - } - - TQString fu = normalizeFunction( function ); - for ( TQValueList<Function>::Iterator it = r->functionList.begin(); it != r->functionList.end(); ++it ) { - if ( fu == normalizeFunction( (*it).function ) ) - return (*it).language; - } - return TQString(); -} - -bool MetaDataBase::addCustomWidget( CustomWidget *wid ) -{ - setupDataBase(); - - for ( CustomWidget *w = cWidgets->first(); w; w = cWidgets->next() ) { - if ( *wid == *w ) { - for ( TQValueList<TQCString>::ConstIterator it = wid->lstSignals.begin(); it != wid->lstSignals.end(); ++it ) { - if ( !w->hasSignal( *it ) ) - w->lstSignals.append( *it ); - } - for ( TQValueList<Function>::ConstIterator it2 = wid->lstSlots.begin(); it2 != wid->lstSlots.end(); ++it2 ) { - if ( !w->hasSlot( MetaDataBase::normalizeFunction( (*it2).function ).latin1() ) ) - w->lstSlots.append( *it2 ); - } - for ( TQValueList<Property>::ConstIterator it3 = wid->lstProperties.begin(); it3 != wid->lstProperties.end(); ++it3 ) { - if ( !w->hasProperty( (*it3).property ) ) - w->lstProperties.append( *it3 ); - } - delete wid; - return FALSE; - } - } - - - WidgetDatabaseRecord *r = new WidgetDatabaseRecord; - r->name = wid->className; - r->includeFile = wid->includeFile; - r->group = WidgetDatabase::widgetGroup( "Custom" ); - r->toolTip = wid->className; - r->icon = new TQIconSet( *wid->pixmap, *wid->pixmap ); - r->isContainer = wid->isContainer; - wid->id = WidgetDatabase::addCustomWidget( r ); - cWidgets->append( wid ); - return TRUE; -} - -void MetaDataBase::removeCustomWidget( CustomWidget *w ) -{ - cWidgets->removeRef( w ); -} - -TQPtrList<MetaDataBase::CustomWidget> *MetaDataBase::customWidgets() -{ - setupDataBase(); - return cWidgets; -} - -MetaDataBase::CustomWidget *MetaDataBase::customWidget( int id ) -{ - for ( CustomWidget *w = cWidgets->first(); w; w = cWidgets->next() ) { - if ( id == w->id ) - return w; - } - return 0; -} - -bool MetaDataBase::isWidgetNameUsed( CustomWidget *wid ) -{ - for ( CustomWidget *w = cWidgets->first(); w; w = cWidgets->next() ) { - if ( w == wid ) - continue; - if ( wid->className == w->className ) - return TRUE; - } - return FALSE; -} - -bool MetaDataBase::hasCustomWidget( const TQString &className ) -{ - for ( CustomWidget *w = cWidgets->first(); w; w = cWidgets->next() ) { - if ( w->className == className ) - return TRUE; - } - return FALSE; -} - -void MetaDataBase::setTabOrder( TQWidget *w, const TQWidgetList &order ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*) w ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - w, w->name(), w->className() ); - return; - } - - r->tabOrder = order; -} - -TQWidgetList MetaDataBase::tabOrder( TQWidget *w ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*) w ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - w, w->name(), w->className() ); - return TQWidgetList(); - } - - return r->tabOrder; -} - -void MetaDataBase::setIncludes( TQT_BASE_OBJECT_NAME *o, const TQValueList<Include> &incs ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->includes = incs; -} - -TQValueList<MetaDataBase::Include> MetaDataBase::includes( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQValueList<Include>(); - } - - return r->includes; -} - -void MetaDataBase::setForwards( TQT_BASE_OBJECT_NAME *o, const TQStringList &fwds ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->forwards = fwds; -} - -TQStringList MetaDataBase::forwards( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQStringList(); - } - - return r->forwards; -} - -void MetaDataBase::setVariables( TQT_BASE_OBJECT_NAME *o, const TQValueList<Variable> &vars ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->variables = vars; -} - -void MetaDataBase::addVariable( TQT_BASE_OBJECT_NAME *o, const TQString &name, const TQString &access ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - Variable v; - v.varName = name; - v.varAccess = access; - r->variables << v; -} - -void MetaDataBase::removeVariable( TQT_BASE_OBJECT_NAME *o, const TQString &name ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - TQValueList<Variable>::Iterator it = r->variables.begin(); - for ( ; it != r->variables.end(); ++it ) { - if ( (*it).varName == name ) { - r->variables.remove( it ); - break; - } - } -} - -TQValueList<MetaDataBase::Variable> MetaDataBase::variables( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQValueList<MetaDataBase::Variable>(); - } - - return r->variables; -} - -bool MetaDataBase::hasVariable( TQT_BASE_OBJECT_NAME *o, const TQString &name ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return FALSE; - } - - TQValueList<Variable>::Iterator it = r->variables.begin(); - for ( ; it != r->variables.end(); ++it ) { - if ( extractVariableName( name ) == extractVariableName( (*it).varName ) ) - return TRUE; - } - return FALSE; -} - -TQString MetaDataBase::extractVariableName( const TQString &name ) -{ - TQString n = name.right( name.length() - name.findRev( ' ' ) - 1 ); - if ( n[ 0 ] == '*' || n[ 0 ] == '&' ) - n[ 0 ] = ' '; - if ( n[ (int)n.length() - 1 ] == ';' ) - n[ (int)n.length() - 1 ] = ' '; - return n.simplifyWhiteSpace(); -} - -void MetaDataBase::setSignalList( TQT_BASE_OBJECT_NAME *o, const TQStringList &sigs ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->sigs.clear(); - - for ( TQStringList::ConstIterator it = sigs.begin(); it != sigs.end(); ++it ) { - TQString s = (*it).simplifyWhiteSpace(); - bool hasSemicolon = s.endsWith( ";" ); - if ( hasSemicolon ) - s = s.left( s.length() - 1 ); - int p = s.find( '(' ); - if ( p < 0 ) - p = s.length(); - int sp = s.find( ' ' ); - if ( sp >= 0 && sp < p ) { - s = s.mid( sp+1 ); - p -= sp + 1; - } - if ( p == (int) s.length() ) - s += "()"; - if ( hasSemicolon ) - s += ";"; - r->sigs << s; - } -} - -TQStringList MetaDataBase::signalList( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQStringList(); - } - - return r->sigs; -} - -void MetaDataBase::setMetaInfo( TQT_BASE_OBJECT_NAME *o, MetaInfo mi ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->metaInfo = mi; -} - -MetaDataBase::MetaInfo MetaDataBase::metaInfo( TQT_BASE_OBJECT_NAME *o ) -{ - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return MetaInfo(); - } - - return r->metaInfo; -} - - - - -MetaDataBase::CustomWidget::CustomWidget() -{ - className = "MyCustomWidget"; - includeFile = "mywidget.h"; - includePolicy = Local; - tqsizeHint = TQSize( -1, -1 ); - pixmap = new TQPixmap( TQPixmap::fromMimeSource( "designer_customwidget.png" ) ); - id = -1; - sizePolicy = TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred ); - isContainer = FALSE; -} - -MetaDataBase::CustomWidget::CustomWidget( const CustomWidget &w ) -{ - className = w.className; - includeFile = w.includeFile; - includePolicy = w.includePolicy; - tqsizeHint = w.tqsizeHint; - if ( w.pixmap ) - pixmap = new TQPixmap( *w.pixmap ); - else - pixmap = 0; - id = w.id; - isContainer = w.isContainer; -} - -void MetaDataBase::setCursor( TQWidget *w, const TQCursor &c ) -{ - setupDataBase(); - if ( w->isA( "PropertyObject" ) ) { - ( (PropertyObject*)w )->mdSetCursor( c ); - return; - } - MetaDataBaseRecord *r = db->find( (void*)w ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - w, w->name(), w->className() ); - return; - } - - r->cursor = c; -} - -TQCursor MetaDataBase::cursor( TQWidget *w ) -{ - setupDataBase(); - if ( w->isA( "PropertyObject" ) ) - return ( (PropertyObject*)w )->mdCursor(); - MetaDataBaseRecord *r = db->find( (void*)w ); - if ( !r ) { - w->unsetCursor(); - return w->cursor(); - } - - return r->cursor; -} - -bool MetaDataBase::CustomWidget::operator==( const CustomWidget &w ) const -{ - return className == w.className; -} - -MetaDataBase::CustomWidget &MetaDataBase::CustomWidget::operator=( const CustomWidget &w ) -{ - delete pixmap; - className = w.className; - includeFile = w.includeFile; - includePolicy = w.includePolicy; - tqsizeHint = w.tqsizeHint; - if ( w.pixmap ) - pixmap = new TQPixmap( *w.pixmap ); - else - pixmap = 0; - lstSignals = w.lstSignals; - lstSlots = w.lstSlots; - lstProperties = w.lstProperties; - id = w.id; - isContainer = w.isContainer; - return *this; -} - -bool MetaDataBase::CustomWidget::hasSignal( const TQCString &signal ) const -{ - TQStrList sigList = TQWidget::tqstaticMetaObject()->signalNames( TRUE ); - if ( sigList.find( signal ) != -1 ) - return TRUE; - for ( TQValueList<TQCString>::ConstIterator it = lstSignals.begin(); it != lstSignals.end(); ++it ) { - if ( normalizeFunction( *it ) == normalizeFunction( signal ) ) - return TRUE; - } - return FALSE; -} - -bool MetaDataBase::CustomWidget::hasSlot( const TQCString &slot ) const -{ - TQStrList slotList = TQWidget::tqstaticMetaObject()->slotNames( TRUE ); - if ( slotList.find( normalizeFunction( slot ) ) != -1 ) - return TRUE; - - for ( TQValueList<MetaDataBase::Function>::ConstIterator it = lstSlots.begin(); it != lstSlots.end(); ++it ) { - if ( normalizeFunction( (*it).function ) == normalizeFunction( slot ) ) - return TRUE; - } - return FALSE; -} - -bool MetaDataBase::CustomWidget::hasProperty( const TQCString &prop ) const -{ - TQStrList propList = TQWidget::tqstaticMetaObject()->propertyNames( TRUE ); - if ( propList.find( prop ) != -1 ) - return TRUE; - - for ( TQValueList<MetaDataBase::Property>::ConstIterator it = lstProperties.begin(); it != lstProperties.end(); ++it ) { - if ( (*it).property == prop ) - return TRUE; - } - return FALSE; -} - -void MetaDataBase::setPixmapArgument( TQT_BASE_OBJECT_NAME *o, int pixmap, const TQString &arg ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->pixmapArguments.remove( pixmap ); - r->pixmapArguments.insert( pixmap, arg ); -} - -TQString MetaDataBase::pixmapArgument( TQT_BASE_OBJECT_NAME *o, int pixmap ) -{ - if ( !o ) - return TQString(); - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQString(); - } - - return *r->pixmapArguments.find( pixmap ); -} - -void MetaDataBase::clearPixmapArguments( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->pixmapArguments.clear(); -} - - -void MetaDataBase::setPixmapKey( TQT_BASE_OBJECT_NAME *o, int pixmap, const TQString &arg ) -{ - if ( !o ) - return; - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) { - ( (PropertyObject*)o )->mdSetPixmapKey( pixmap, arg ); - return; - } - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->pixmapKeys.remove( pixmap ); - r->pixmapKeys.insert( pixmap, arg ); -} - -TQString MetaDataBase::pixmapKey( TQT_BASE_OBJECT_NAME *o, int pixmap ) -{ - if ( !o ) - return TQString(); - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) - return ( (PropertyObject*)o )->mdPixmapKey( pixmap ); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQString(); - } - - TQString s = *r->pixmapKeys.find( pixmap ); - if ( !s.isNull() ) - return s; - if ( !o->isWidgetType() ) - return s; - TQWidget *w = (TQWidget*)o; - if ( w->icon() ) - return *r->pixmapKeys.find( w->icon()->serialNumber() ); - return s; -} - -void MetaDataBase::clearPixmapKeys( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->pixmapKeys.clear(); -} - - - -void MetaDataBase::setColumnFields( TQT_BASE_OBJECT_NAME *o, const TQMap<TQString, TQString> &columnFields ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->columnFields = columnFields; -} - -TQMap<TQString, TQString> MetaDataBase::columnFields( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return TQMap<TQString, TQString>(); - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQMap<TQString, TQString>(); - } - - return r->columnFields; -} - -void MetaDataBase::setEditor( const TQStringList &langs ) -{ - editorLangList = langs; -} - -bool MetaDataBase::hasEditor( const TQString &lang ) -{ - return editorLangList.find( lang ) != editorLangList.end(); -} - -void MetaDataBase::setupInterfaceManagers( const TQString &plugDir ) -{ - if ( !languageInterfaceManager ) { - languageInterfaceManager = - new TQPluginManager<LanguageInterface>( IID_Language, - TQApplication::libraryPaths(), - plugDir ); - - langList = languageInterfaceManager->featureList(); - langList.remove( "C++" ); - langList << "C++"; - } -} - -TQStringList MetaDataBase::languages() -{ - return langList; -} - -TQString MetaDataBase::normalizeFunction( const TQString &f ) -{ - return Parser::cleanArgs( f ); -} - -LanguageInterface *MetaDataBase::languageInterface( const TQString &lang ) -{ - LanguageInterface* iface = 0; - languageInterfaceManager->queryInterface( lang, &iface ); - return iface; -} - -void MetaDataBase::clear( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return; - setupDataBase(); - db->remove( (void*)o ); - for ( TQPtrDictIterator<TQWidget> it( *( (FormWindow*)o )->widgets() ); it.current(); ++it ) - db->remove( (void*)it.current() ); -} - -void MetaDataBase::setBreakPoints( TQT_BASE_OBJECT_NAME *o, const TQValueList<uint> &l ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->breakPoints = l; - - TQMap<int, TQString>::Iterator it = r->breakPointConditions.begin(); - while ( it != r->breakPointConditions.end() ) { - int line = it.key(); - ++it; - if ( r->breakPoints.find( line ) == r->breakPoints.end() ) - r->breakPointConditions.remove( r->breakPointConditions.find( line ) ); - } -} - -TQValueList<uint> MetaDataBase::breakPoints( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return TQValueList<uint>(); - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQValueList<uint>(); - } - - return r->breakPoints; -} - -void MetaDataBase::setBreakPointCondition( TQT_BASE_OBJECT_NAME *o, int line, const TQString &condition ) -{ - if ( !o ) - return; - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - r->breakPointConditions.replace( line, condition ); -} - -TQString MetaDataBase::breakPointCondition( TQT_BASE_OBJECT_NAME *o, int line ) -{ - if ( !o ) - return TQString(); - setupDataBase(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return TQString(); - } - TQMap<int, TQString>::Iterator it = r->breakPointConditions.find( line ); - if ( it == r->breakPointConditions.end() ) - return TQString(); - return *it; -} - -void MetaDataBase::setExportMacro( TQT_BASE_OBJECT_NAME *o, const TQString ¯o ) -{ - if ( !o ) - return; - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) { - ( (PropertyObject*)o )->mdSetExportMacro( macro ); - return; - } - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return; - } - - r->exportMacro = macro; -} - -TQString MetaDataBase::exportMacro( TQT_BASE_OBJECT_NAME *o ) -{ - if ( !o ) - return ""; - setupDataBase(); - if ( TQT_TQOBJECT(o)->isA( "PropertyObject" ) ) - return ( (PropertyObject*)o )->mdExportMacro(); - MetaDataBaseRecord *r = db->find( (void*)o ); - if ( !r ) { - qWarning( "No entry for %p (%s, %s) found in MetaDataBase", - o, TQT_TQOBJECT(o)->name(), TQT_TQOBJECT(o)->className() ); - return ""; - } - - return r->exportMacro; -} - -bool MetaDataBase::hasObject( TQT_BASE_OBJECT_NAME *o ) -{ - return !!db->find( o ); -} |