You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
4.8 KiB
159 lines
4.8 KiB
15 years ago
|
/**********************************************************************
|
||
|
** Copyright (C) 2002 Trolltech AS. All rights reserved.
|
||
|
**
|
||
14 years ago
|
** This file is part of TQt Designer.
|
||
15 years ago
|
**
|
||
|
** This file may be distributed and/or modified under the terms of the
|
||
|
** GNU General Public License version 2 as published by the Free Software
|
||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||
|
** packaging of this file.
|
||
|
**
|
||
14 years ago
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||
15 years ago
|
** Agreement provided with the Software.
|
||
|
**
|
||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||
|
**
|
||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||
14 years ago
|
** information about TQt Commercial License Agreements.
|
||
15 years ago
|
**
|
||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||
|
** not clear to you.
|
||
|
**
|
||
|
**********************************************************************/
|
||
|
|
||
|
#include "propertyobject.h"
|
||
|
#include "metadatabase.h"
|
||
15 years ago
|
#include <tqptrvector.h>
|
||
|
#include <tqptrlist.h>
|
||
|
#include <tqmetaobject.h>
|
||
|
#include <tqvariant.h>
|
||
15 years ago
|
|
||
15 years ago
|
PropertyObject::PropertyObject( const TQWidgetList &objs )
|
||
|
: TQObject(), objects( objs ), mobj( 0 )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQPtrVector<TQPtrList<TQMetaObject> > v;
|
||
15 years ago
|
v.resize( objects.count() );
|
||
|
v.setAutoDelete( TRUE );
|
||
|
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) ) {
|
||
13 years ago
|
const TQMetaObject *m = o->metaObject();
|
||
15 years ago
|
TQPtrList<TQMetaObject> *mol = new TQPtrList<TQMetaObject>;
|
||
15 years ago
|
while ( m ) {
|
||
|
mol->insert( 0, m );
|
||
13 years ago
|
m = m->superClass();
|
||
15 years ago
|
}
|
||
|
v.insert( v.count(), mol );
|
||
|
}
|
||
|
|
||
|
int numObjects = objects.count();
|
||
|
int minDepth = v[0]->count();
|
||
|
int depth = minDepth;
|
||
|
|
||
|
for ( int i = 0; i < numObjects; ++i ) {
|
||
|
depth = (int)v[i]->count();
|
||
|
if ( depth < minDepth )
|
||
|
minDepth = depth;
|
||
|
}
|
||
|
|
||
15 years ago
|
const TQMetaObject *m = v[0]->at( --minDepth );
|
||
15 years ago
|
|
||
|
for ( int j = 0; j < numObjects; ++j ) {
|
||
|
if ( v[j]->at( minDepth ) != m ) {
|
||
|
m = v[0]->at( --minDepth );
|
||
|
j = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
mobj = m;
|
||
|
|
||
|
Q_ASSERT( mobj );
|
||
|
}
|
||
|
|
||
15 years ago
|
bool PropertyObject::setProperty( const char *name, const TQVariant& value )
|
||
15 years ago
|
{
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) )
|
||
15 years ago
|
o->setProperty( name, value );
|
||
|
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQVariant PropertyObject::property( const char *name ) const
|
||
15 years ago
|
{
|
||
|
return ( (PropertyObject*)this )->objects.first()->property( name );
|
||
|
}
|
||
|
|
||
15 years ago
|
void PropertyObject::mdPropertyChanged( const TQString &property, bool changed )
|
||
15 years ago
|
{
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) )
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, property, changed );
|
||
|
}
|
||
|
|
||
15 years ago
|
bool PropertyObject::mdIsPropertyChanged( const TQString &property )
|
||
15 years ago
|
{
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) ) {
|
||
15 years ago
|
if ( MetaDataBase::isPropertyChanged( o, property ) )
|
||
|
return TRUE;
|
||
|
}
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
15 years ago
|
void PropertyObject::mdSetPropertyComment( const TQString &property, const TQString &comment )
|
||
15 years ago
|
{
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) )
|
||
15 years ago
|
MetaDataBase::setPropertyComment( o, property, comment );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString PropertyObject::mdPropertyComment( const TQString &property )
|
||
15 years ago
|
{
|
||
14 years ago
|
return MetaDataBase::propertyComment( TQT_TQOBJECT(objects.first()), property );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void PropertyObject::mdSetFakeProperty( const TQString &property, const TQVariant &value )
|
||
15 years ago
|
{
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) )
|
||
15 years ago
|
MetaDataBase::setFakeProperty( o, property, value );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQVariant PropertyObject::mdFakeProperty( const TQString &property )
|
||
15 years ago
|
{
|
||
14 years ago
|
return MetaDataBase::fakeProperty( TQT_TQOBJECT(objects.first()), property );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void PropertyObject::mdSetCursor( const TQCursor &c )
|
||
15 years ago
|
{
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) ) {
|
||
15 years ago
|
if ( o->isWidgetType() )
|
||
15 years ago
|
MetaDataBase::setCursor( (TQWidget*)o, c );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQCursor PropertyObject::mdCursor()
|
||
15 years ago
|
{
|
||
|
return MetaDataBase::cursor( objects.first() );
|
||
|
}
|
||
|
|
||
15 years ago
|
void PropertyObject::mdSetPixmapKey( int pixmap, const TQString &arg )
|
||
15 years ago
|
{
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) )
|
||
15 years ago
|
MetaDataBase::setPixmapKey( o, pixmap, arg );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString PropertyObject::mdPixmapKey( int pixmap )
|
||
15 years ago
|
{
|
||
14 years ago
|
return MetaDataBase::pixmapKey( TQT_TQOBJECT(objects.first()), pixmap );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void PropertyObject::mdSetExportMacro( const TQString ¯o )
|
||
15 years ago
|
{
|
||
14 years ago
|
for ( TQObject *o = TQT_TQOBJECT(objects.first()); o; o = TQT_TQOBJECT(objects.next()) )
|
||
15 years ago
|
MetaDataBase::setExportMacro( o, macro );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString PropertyObject::mdExportMacro()
|
||
15 years ago
|
{
|
||
14 years ago
|
return MetaDataBase::exportMacro( TQT_TQOBJECT(objects.first()) );
|
||
15 years ago
|
}
|