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.
1806 lines
55 KiB
1806 lines
55 KiB
15 years ago
|
/**********************************************************************
|
||
|
** Copyright (C) 2000-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.
|
||
|
**
|
||
|
**********************************************************************/
|
||
|
|
||
15 years ago
|
#include <tqvariant.h> // HP-UX compiler need this here
|
||
15 years ago
|
#include "widgetfactory.h"
|
||
|
#include <widgetdatabase.h>
|
||
|
#include "metadatabase.h"
|
||
|
#include "mainwindow.h"
|
||
|
#include "formwindow.h"
|
||
|
#include "propertyeditor.h"
|
||
13 years ago
|
#include "tqlayout.h"
|
||
15 years ago
|
#include "listboxeditorimpl.h"
|
||
|
#include "listvieweditorimpl.h"
|
||
|
#include "iconvieweditorimpl.h"
|
||
|
#include "formwindow.h"
|
||
|
#include "multilineeditorimpl.h"
|
||
|
#include "../interfaces/widgetinterface.h"
|
||
14 years ago
|
#ifndef TQT_NO_TABLE
|
||
15 years ago
|
#include "tableeditorimpl.h"
|
||
|
#endif
|
||
|
#include "project.h"
|
||
|
#include "menubareditor.h"
|
||
|
#include "popupmenueditor.h"
|
||
|
|
||
11 years ago
|
#include "tdevdesigner_part.h"
|
||
15 years ago
|
|
||
|
#include <kiconloader.h>
|
||
|
|
||
15 years ago
|
#include <tqfeatures.h>
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqpixmap.h>
|
||
|
#include <tqgroupbox.h>
|
||
|
#include <tqiconview.h>
|
||
14 years ago
|
#ifndef TQT_NO_TABLE
|
||
15 years ago
|
#include <tqtable.h>
|
||
15 years ago
|
#endif
|
||
14 years ago
|
#ifndef TQT_NO_SQL
|
||
15 years ago
|
#include <tqdatatable.h>
|
||
15 years ago
|
#endif
|
||
15 years ago
|
#include <tqdatetimeedit.h>
|
||
|
#include <tqlineedit.h>
|
||
|
#include <tqspinbox.h>
|
||
|
#include <tqmultilineedit.h>
|
||
13 years ago
|
#include <tqtextedit.h>
|
||
15 years ago
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqwidgetstack.h>
|
||
|
#include <tqcombobox.h>
|
||
|
#include <tqtabbar.h>
|
||
|
#include <tqlistbox.h>
|
||
|
#include <tqlistview.h>
|
||
|
#include <tqobjectlist.h>
|
||
|
#include <tqlcdnumber.h>
|
||
|
#include <tqslider.h>
|
||
|
#include <tqdial.h>
|
||
|
#include <tqprogressbar.h>
|
||
13 years ago
|
#include <tqtextview.h>
|
||
|
#include <tqtextbrowser.h>
|
||
15 years ago
|
#include <tqframe.h>
|
||
|
#include <tqmetaobject.h>
|
||
|
#include <tqwidgetstack.h>
|
||
|
#include <tqwizard.h>
|
||
|
#include <tqvaluelist.h>
|
||
|
#include <tqtimer.h>
|
||
|
#include <tqscrollbar.h>
|
||
|
#include <tqmainwindow.h>
|
||
|
#include <tqmenubar.h>
|
||
|
#include <tqapplication.h>
|
||
|
#include <tqsplitter.h>
|
||
|
#include <tqtoolbox.h>
|
||
|
#include <tqsizegrip.h>
|
||
14 years ago
|
#ifndef TQT_NO_SQL
|
||
15 years ago
|
#include "database.h"
|
||
|
#endif
|
||
|
|
||
|
#define NO_STATIC_COLORS
|
||
|
#include <globaldefs.h>
|
||
15 years ago
|
#include <tqobject.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
15 years ago
|
FormWindow *find_formwindow( TQWidget *w )
|
||
15 years ago
|
{
|
||
|
if ( !w )
|
||
|
return 0;
|
||
|
for (;;) {
|
||
14 years ago
|
if ( ::tqqt_cast<FormWindow*>(w) )
|
||
15 years ago
|
return (FormWindow*)w;
|
||
14 years ago
|
if ( !w->parentWidget() )
|
||
15 years ago
|
return 0;
|
||
14 years ago
|
w = w->parentWidget();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void TQLayoutWidget::paintEvent( TQPaintEvent* )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQPainter p ( this );
|
||
15 years ago
|
p.setPen( red );
|
||
|
p.drawRect( rect() );
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
QDesignerTabWidget::QDesignerTabWidget( TQWidget *parent, const char *name )
|
||
|
: TQTabWidget( parent, name ), dropIndicator( 0 ), dragPage( 0 ), mousePressed( FALSE )
|
||
15 years ago
|
{
|
||
|
tabBar()->setAcceptDrops( TRUE );
|
||
|
tabBar()->installEventFilter( this );
|
||
|
}
|
||
|
|
||
14 years ago
|
int QDesignerTabWidget::currentPage() const
|
||
15 years ago
|
{
|
||
|
return tabBar()->currentTab();
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerTabWidget::setCurrentPage( int i )
|
||
15 years ago
|
{
|
||
|
tabBar()->setCurrentTab( i );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString QDesignerTabWidget::pageTitle() const
|
||
15 years ago
|
{
|
||
15 years ago
|
return ((TQTabWidget*)this)->tabLabel( TQTabWidget::currentPage() );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void QDesignerTabWidget::setPageTitle( const TQString& title )
|
||
15 years ago
|
{
|
||
15 years ago
|
changeTab( TQTabWidget::currentPage(), title );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void QDesignerTabWidget::setPageName( const TQCString& name )
|
||
15 years ago
|
{
|
||
15 years ago
|
if ( TQTabWidget::currentPage() )
|
||
|
TQTabWidget::currentPage()->setName( name );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
TQCString QDesignerTabWidget::pageName() const
|
||
15 years ago
|
{
|
||
15 years ago
|
if ( !TQTabWidget::currentPage() )
|
||
15 years ago
|
return 0;
|
||
15 years ago
|
return TQTabWidget::currentPage()->name();
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
int QDesignerTabWidget::count() const
|
||
15 years ago
|
{
|
||
|
return tabBar()->count();
|
||
|
}
|
||
|
|
||
14 years ago
|
bool QDesignerTabWidget::eventFilter( TQObject *o, TQEvent *e )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(tabBar()) ) return FALSE;
|
||
15 years ago
|
|
||
|
switch ( e->type() ) {
|
||
15 years ago
|
case TQEvent::MouseButtonPress: {
|
||
15 years ago
|
mousePressed = TRUE;
|
||
15 years ago
|
TQMouseEvent *me = (TQMouseEvent*)e;
|
||
15 years ago
|
pressPoint = me->pos();
|
||
|
}
|
||
|
break;
|
||
15 years ago
|
case TQEvent::MouseMove: {
|
||
|
TQMouseEvent *me = (TQMouseEvent*)e;
|
||
|
if ( mousePressed && ( pressPoint - me->pos()).manhattanLength() > TQApplication::startDragDistance() ) {
|
||
|
TQTextDrag *drg = new TQTextDrag( TQString::number( (long) this ) , this );
|
||
15 years ago
|
mousePressed = FALSE;
|
||
15 years ago
|
dragPage = TQTabWidget::currentPage();
|
||
|
dragLabel = TQTabWidget::tabLabel( dragPage );
|
||
15 years ago
|
|
||
|
int index = indexOf( dragPage );
|
||
|
|
||
|
removePage( dragPage );
|
||
|
if ( !drg->dragMove() ) {
|
||
|
insertTab( dragPage, dragLabel, index );
|
||
|
showPage( dragPage );
|
||
|
}
|
||
|
if ( dropIndicator )
|
||
|
dropIndicator->hide();
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
15 years ago
|
case TQEvent::DragLeave: {
|
||
15 years ago
|
if ( dropIndicator )
|
||
|
dropIndicator->hide();
|
||
|
}
|
||
|
break;
|
||
15 years ago
|
case TQEvent::DragMove: {
|
||
|
TQDragEnterEvent *de = (TQDragEnterEvent*) e;
|
||
|
if ( TQTextDrag::canDecode( de ) ) {
|
||
|
TQString text;
|
||
|
TQTextDrag::decode( de, text );
|
||
|
if ( text == TQString::number( (long)this ) )
|
||
15 years ago
|
de->accept();
|
||
|
else
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
|
int index = 0;
|
||
15 years ago
|
TQRect rect;
|
||
15 years ago
|
for ( ; index < tabBar()->count(); index++ ) {
|
||
14 years ago
|
if ( tabBar()->tabAt( index )->rect().contains( de->pos() ) ) {
|
||
15 years ago
|
rect = tabBar()->tabAt( index )->rect();
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( index == tabBar()->count() -1 ) {
|
||
15 years ago
|
TQRect rect2 = rect;
|
||
15 years ago
|
rect2.setLeft( rect2.left() + rect2.width() / 2 );
|
||
14 years ago
|
if ( rect2.contains( de->pos() ) )
|
||
15 years ago
|
index++;
|
||
|
}
|
||
|
|
||
|
if ( ! dropIndicator ) {
|
||
15 years ago
|
dropIndicator = new TQWidget( this );
|
||
15 years ago
|
dropIndicator->setBackgroundColor( red );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQPoint pos;
|
||
15 years ago
|
if ( index == tabBar()->count() )
|
||
15 years ago
|
pos = tabBar()->mapToParent( TQPoint( rect.x() + rect.width(), rect.y() ) );
|
||
15 years ago
|
else
|
||
15 years ago
|
pos = tabBar()->mapToParent( TQPoint( rect.x(), rect.y() ) );
|
||
15 years ago
|
|
||
|
dropIndicator->setGeometry( pos.x(), pos.y() , 3, rect.height() );
|
||
|
dropIndicator->show();
|
||
|
}
|
||
|
break;
|
||
15 years ago
|
case TQEvent::Drop: {
|
||
|
TQDragEnterEvent *de = (TQDragEnterEvent*) e;
|
||
|
if ( TQTextDrag::canDecode( de ) ) {
|
||
|
TQString text;
|
||
|
TQTextDrag::decode( de, text );
|
||
|
if ( text == TQString::number( (long)this ) ) {
|
||
15 years ago
|
|
||
|
int newIndex = 0;
|
||
|
for ( ; newIndex < tabBar()->count(); newIndex++ ) {
|
||
14 years ago
|
if ( tabBar()->tabAt( newIndex )->rect().contains( de->pos() ) )
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
|
||
|
if ( newIndex == tabBar()->count() -1 ) {
|
||
15 years ago
|
TQRect rect2 = tabBar()->tabAt( newIndex )->rect();
|
||
15 years ago
|
rect2.setLeft( rect2.left() + rect2.width() / 2 );
|
||
14 years ago
|
if ( rect2.contains( de->pos() ) )
|
||
15 years ago
|
newIndex++;
|
||
|
}
|
||
|
|
||
|
int oldIndex = 0;
|
||
|
for ( ; oldIndex < tabBar()->count(); oldIndex++ ) {
|
||
14 years ago
|
if ( tabBar()->tabAt( oldIndex )->rect().contains( pressPoint ) )
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
|
||
|
FormWindow *fw = find_formwindow( this );
|
||
|
MoveTabPageCommand *cmd =
|
||
|
new MoveTabPageCommand( i18n( "Move Tab Page" ), fw, this,
|
||
|
dragPage, dragLabel, newIndex, oldIndex );
|
||
|
fw->commandHistory()->addCommand( cmd );
|
||
|
cmd->execute();
|
||
|
de->accept();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
QDesignerWidgetStack::QDesignerWidgetStack( TQWidget *parent, const char *name )
|
||
|
: TQWidgetStack( parent, name )
|
||
15 years ago
|
{
|
||
14 years ago
|
prev = new TQToolButton( TQt::LeftArrow, this, "designer_wizardstack_button" );
|
||
15 years ago
|
prev->setAutoRaise( TRUE );
|
||
|
prev->setAutoRepeat( TRUE );
|
||
13 years ago
|
prev->setSizePolicy( TQSizePolicy( TQSizePolicy::Ignored, TQSizePolicy::Ignored ) );
|
||
14 years ago
|
next = new TQToolButton( TQt::RightArrow, this, "designer_wizardstack_button" );
|
||
15 years ago
|
next->setAutoRaise( TRUE );
|
||
|
next->setAutoRepeat( TRUE );
|
||
13 years ago
|
next->setSizePolicy( TQSizePolicy( TQSizePolicy::Ignored, TQSizePolicy::Ignored ) );
|
||
15 years ago
|
connect( prev, TQT_SIGNAL( clicked() ), this, TQT_SLOT( prevPage() ) );
|
||
|
connect( next, TQT_SIGNAL( clicked() ), this, TQT_SLOT( nextPage() ) );
|
||
15 years ago
|
updateButtons();
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWidgetStack::updateButtons()
|
||
15 years ago
|
{
|
||
|
prev->setGeometry( width() - 31, 1, 15, 15 );
|
||
|
next->setGeometry( width() - 16, 1, 15, 15 );
|
||
|
prev->show();
|
||
|
next->show();
|
||
|
prev->raise();
|
||
|
next->raise();
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWidgetStack::prevPage()
|
||
15 years ago
|
{
|
||
|
setCurrentPage( currentPage() - 1 );
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWidgetStack::nextPage()
|
||
15 years ago
|
{
|
||
|
setCurrentPage( currentPage() + 1 );
|
||
|
}
|
||
|
|
||
14 years ago
|
int QDesignerWidgetStack::currentPage() const
|
||
15 years ago
|
{
|
||
14 years ago
|
QDesignerWidgetStack* that = (QDesignerWidgetStack*) this;
|
||
14 years ago
|
return that->pages.find( visibleWidget() );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWidgetStack::setCurrentPage( int i )
|
||
15 years ago
|
{
|
||
|
// help next/prev page commands
|
||
|
if ( i < 0 )
|
||
|
i += count();
|
||
|
if ( i >= count() )
|
||
|
i -= count();
|
||
|
|
||
|
if ( i < 0 || i >= count() )
|
||
|
return;
|
||
|
raiseWidget( pages.at( i ) );
|
||
|
updateButtons();
|
||
|
}
|
||
|
|
||
14 years ago
|
TQCString QDesignerWidgetStack::pageName() const
|
||
15 years ago
|
{
|
||
|
if ( !visibleWidget() )
|
||
|
return 0;
|
||
|
return visibleWidget()->name();
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWidgetStack::setPageName( const TQCString& name )
|
||
15 years ago
|
{
|
||
|
if ( visibleWidget() )
|
||
|
visibleWidget()->setName( name );
|
||
|
}
|
||
|
|
||
14 years ago
|
int QDesignerWidgetStack::count() const
|
||
15 years ago
|
{
|
||
|
return pages.count();
|
||
|
}
|
||
|
|
||
14 years ago
|
TQWidget* QDesignerWidgetStack::page( int i ) const
|
||
15 years ago
|
{
|
||
|
if ( i < 0 || i >= count() )
|
||
|
return 0;
|
||
14 years ago
|
QDesignerWidgetStack* that = (QDesignerWidgetStack*) this;
|
||
15 years ago
|
return that->pages.at( i );
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
int QDesignerWidgetStack::insertPage( TQWidget *p, int i )
|
||
15 years ago
|
{
|
||
|
if ( i < 0 )
|
||
|
pages.append( p );
|
||
|
else
|
||
|
pages.insert( (uint) i, p );
|
||
|
addWidget( p );
|
||
|
p->show();
|
||
|
raiseWidget( p );
|
||
15 years ago
|
TQApplication::sendPostedEvents();
|
||
15 years ago
|
updateButtons();
|
||
14 years ago
|
return pages.find( p );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
int QDesignerWidgetStack::removePage( TQWidget *p )
|
||
15 years ago
|
{
|
||
14 years ago
|
int i = pages.find( p );
|
||
15 years ago
|
pages.remove( p );
|
||
|
removeWidget( p );
|
||
|
setCurrentPage( 0 );
|
||
|
updateButtons();
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
int QDesignerWizard::currentPageNum() const
|
||
15 years ago
|
{
|
||
|
for ( int i = 0; i < pageCount(); ++i ) {
|
||
|
if ( page( i ) == currentPage() )
|
||
|
return i;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
14 years ago
|
void QDesignerWizard::setCurrentPage( int i )
|
||
15 years ago
|
{
|
||
|
if ( i < currentPageNum() ) {
|
||
|
while ( i < currentPageNum() ) {
|
||
|
if ( currentPageNum() == 0 )
|
||
|
break;
|
||
|
back();
|
||
|
}
|
||
|
|
||
|
} else {
|
||
|
while ( i > currentPageNum() ) {
|
||
|
if ( currentPageNum() == pageCount() - 1 )
|
||
|
break;
|
||
|
next();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString QDesignerWizard::pageTitle() const
|
||
15 years ago
|
{
|
||
|
return title( currentPage() );
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWizard::setPageTitle( const TQString& title )
|
||
15 years ago
|
{
|
||
|
setTitle( currentPage(), title );
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWizard::setPageName( const TQCString& name )
|
||
15 years ago
|
{
|
||
15 years ago
|
if ( TQWizard::currentPage() )
|
||
|
TQWizard::currentPage()->setName( name );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
TQCString QDesignerWizard::pageName() const
|
||
15 years ago
|
{
|
||
15 years ago
|
if ( !TQWizard::currentPage() )
|
||
15 years ago
|
return 0;
|
||
15 years ago
|
return TQWizard::currentPage()->name();
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
int QDesignerWizard::pageNum( TQWidget *p )
|
||
15 years ago
|
{
|
||
|
for ( int i = 0; i < pageCount(); ++i ) {
|
||
|
if ( page( i ) == p )
|
||
|
return i;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWizard::addPage( TQWidget *p, const TQString &t )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWizard::addPage( p, t );
|
||
14 years ago
|
if ( removedPages.find( p ) )
|
||
15 years ago
|
removedPages.remove( p );
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWizard::removePage( TQWidget *p )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWizard::removePage( p );
|
||
15 years ago
|
removedPages.insert( p, p );
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWizard::insertPage( TQWidget *p, const TQString &t, int index )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWizard::insertPage( p, t, index );
|
||
14 years ago
|
if ( removedPages.find( p ) )
|
||
15 years ago
|
removedPages.remove( p );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQMap< int, TQMap< TQString, TQVariant> > *defaultProperties = 0;
|
||
|
TQMap< int, TQStringList > *changedProperties = 0;
|
||
15 years ago
|
|
||
|
/*!
|
||
|
\class WidgetFactory widgetfactory.h
|
||
14 years ago
|
\brief Set of static functions for creating widgets, layouts and do other stuff
|
||
15 years ago
|
|
||
|
The widget factory offers functions to create widgets, create and
|
||
14 years ago
|
delete layouts find out other details - all based on the
|
||
15 years ago
|
WidgetDatabase's data. So the functions that use ids use the same
|
||
|
ids as in the WidgetDatabase.
|
||
|
*/
|
||
|
|
||
|
|
||
15 years ago
|
void WidgetFactory::saveDefaultProperties( TQObject *w, int id )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQMap< TQString, TQVariant> propMap;
|
||
13 years ago
|
TQStrList lst = w->metaObject()->propertyNames( TRUE );
|
||
15 years ago
|
for ( uint i = 0; i < lst.count(); ++i ) {
|
||
15 years ago
|
TQVariant var = w->property( lst.at( i ) );
|
||
15 years ago
|
if ( !var.isValid() && qstrcmp( "pixmap", lst.at( i ) ) == 0 )
|
||
15 years ago
|
var = TQVariant( TQPixmap() );
|
||
15 years ago
|
else if ( !var.isValid() && qstrcmp( "iconSet", lst.at( i ) ) == 0 )
|
||
15 years ago
|
var = TQVariant( TQIconSet() );
|
||
14 years ago
|
propMap.replace( lst.at( i ), var );
|
||
15 years ago
|
}
|
||
14 years ago
|
defaultProperties->replace( id, propMap );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void WidgetFactory::saveChangedProperties( TQObject *w, int id )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList l = MetaDataBase::changedProperties( w );
|
||
15 years ago
|
changedProperties->insert( id, l );
|
||
|
}
|
||
|
|
||
|
/*! Creates a widget of the type which is registered as \a id as
|
||
14 years ago
|
child of \a parent. The \a name is optional. If \a init is TRUE, the
|
||
15 years ago
|
widget is initialized with some defaults, else the plain widget is
|
||
|
created.
|
||
|
*/
|
||
|
|
||
14 years ago
|
TQWidget *WidgetFactory::create( int id, TQWidget *parent, const char *name, bool init, const TQRect *r, Qt::Orientation orient )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString n = WidgetDatabase::className( id );
|
||
15 years ago
|
if ( n.isEmpty() )
|
||
|
return 0;
|
||
|
|
||
|
if ( !defaultProperties ) {
|
||
15 years ago
|
defaultProperties = new TQMap< int, TQMap< TQString, TQVariant> >();
|
||
|
changedProperties = new TQMap< int, TQStringList >();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQWidget *w = 0;
|
||
|
TQString str = WidgetDatabase::createWidgetName( id );
|
||
15 years ago
|
const char *s = str.latin1();
|
||
14 years ago
|
w = createWidget( n, parent, name ? name : s, init, r, orient );
|
||
14 years ago
|
if ( ::tqqt_cast<TQScrollView*>(w) )
|
||
15 years ago
|
( (TQScrollView*)w )->disableSizeHintCaching();
|
||
15 years ago
|
if ( !w && WidgetDatabase::isCustomWidget( id ) )
|
||
14 years ago
|
w = createCustomWidget( parent, name ? name : s, MetaDataBase::customWidget( id ) );
|
||
15 years ago
|
if ( !w )
|
||
|
return 0;
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(w) );
|
||
15 years ago
|
|
||
14 years ago
|
if ( !defaultProperties->contains( id ) )
|
||
14 years ago
|
saveDefaultProperties( TQT_TQOBJECT(w), id );
|
||
14 years ago
|
if ( !changedProperties->contains( id ) )
|
||
14 years ago
|
saveChangedProperties( TQT_TQOBJECT(w), id );
|
||
15 years ago
|
|
||
|
return w;
|
||
|
}
|
||
|
|
||
13 years ago
|
/*! Creates a layout on the widget \a widget of the type \a type
|
||
15 years ago
|
which can be \c HBox, \c VBox or \c Grid.
|
||
|
*/
|
||
|
|
||
13 years ago
|
TQLayout *WidgetFactory::createLayout( TQWidget *widget, TQLayout *layout, LayoutType type )
|
||
15 years ago
|
{
|
||
|
int spacing = MainWindow::self->currentLayoutDefaultSpacing();
|
||
|
int margin = 0;
|
||
|
|
||
14 years ago
|
int metaspacing = MetaDataBase::spacing( TQT_TQOBJECT(widget) );
|
||
|
int metamargin = MetaDataBase::margin( TQT_TQOBJECT(widget) );
|
||
15 years ago
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQLayoutWidget*>(widget) &&
|
||
|
( WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(widget) ) ) ) ||
|
||
14 years ago
|
widget && ::tqqt_cast<FormWindow*>(widget->parentWidget()) ) )
|
||
15 years ago
|
margin = MainWindow::self->currentLayoutDefaultMargin();
|
||
|
|
||
13 years ago
|
if ( !layout && ::tqqt_cast<TQTabWidget*>(widget) )
|
||
15 years ago
|
widget = ((TQTabWidget*)widget)->currentPage();
|
||
15 years ago
|
|
||
13 years ago
|
if ( !layout && ::tqqt_cast<TQWizard*>(widget) )
|
||
15 years ago
|
widget = ((TQWizard*)widget)->currentPage();
|
||
15 years ago
|
|
||
13 years ago
|
if ( !layout && ::tqqt_cast<TQMainWindow*>(widget) )
|
||
15 years ago
|
widget = ((TQMainWindow*)widget)->centralWidget();
|
||
15 years ago
|
|
||
13 years ago
|
if ( !layout && ::tqqt_cast<TQWidgetStack*>(widget) )
|
||
15 years ago
|
widget = ((TQWidgetStack*)widget)->visibleWidget();
|
||
15 years ago
|
|
||
13 years ago
|
if ( !layout && ::tqqt_cast<TQToolBox*>(widget) )
|
||
15 years ago
|
widget = ((TQToolBox*)widget)->currentItem();
|
||
15 years ago
|
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(widget) );
|
||
15 years ago
|
|
||
15 years ago
|
TQLayout *l = 0;
|
||
15 years ago
|
int align = 0;
|
||
13 years ago
|
if ( !layout && ::tqqt_cast<TQGroupBox*>(widget) ) {
|
||
15 years ago
|
TQGroupBox *gb = (TQGroupBox*)widget;
|
||
15 years ago
|
gb->setColumnLayout( 0, Qt::Vertical );
|
||
13 years ago
|
layout = gb->layout();
|
||
|
layout->setMargin( 0 );
|
||
|
layout->setSpacing( 0 );
|
||
15 years ago
|
switch ( type ) {
|
||
|
case HBox:
|
||
13 years ago
|
l = new TQHBoxLayout( layout );
|
||
15 years ago
|
break;
|
||
|
case VBox:
|
||
13 years ago
|
l = new TQVBoxLayout( layout );
|
||
15 years ago
|
break;
|
||
|
case Grid:
|
||
13 years ago
|
l = new QDesignerGridLayout( layout );
|
||
15 years ago
|
break;
|
||
|
default:
|
||
|
return 0;
|
||
|
}
|
||
14 years ago
|
align = TQt::AlignTop;
|
||
|
MetaDataBase::setMargin( TQT_TQOBJECT(gb), metamargin );
|
||
|
MetaDataBase::setSpacing( TQT_TQOBJECT(gb), metaspacing );
|
||
15 years ago
|
} else {
|
||
13 years ago
|
if ( layout ) {
|
||
15 years ago
|
switch ( type ) {
|
||
|
case HBox:
|
||
13 years ago
|
l = new TQHBoxLayout( layout );
|
||
15 years ago
|
break;
|
||
|
case VBox:
|
||
13 years ago
|
l = new TQVBoxLayout( layout );
|
||
15 years ago
|
break;
|
||
|
case Grid:
|
||
13 years ago
|
l = new QDesignerGridLayout( layout );
|
||
15 years ago
|
break;
|
||
|
default:
|
||
|
return 0;
|
||
|
}
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
||
15 years ago
|
l->setSpacing( spacing );
|
||
|
l->setMargin( margin );
|
||
|
} else {
|
||
|
switch ( type ) {
|
||
|
case HBox:
|
||
15 years ago
|
l = new TQHBoxLayout( widget );
|
||
15 years ago
|
break;
|
||
|
case VBox:
|
||
15 years ago
|
l = new TQVBoxLayout( widget );
|
||
15 years ago
|
break;
|
||
|
case Grid:
|
||
14 years ago
|
l = new QDesignerGridLayout( widget );
|
||
15 years ago
|
break;
|
||
|
default:
|
||
|
return 0;
|
||
|
}
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
||
15 years ago
|
if ( widget ) {
|
||
14 years ago
|
MetaDataBase::setMargin( TQT_TQOBJECT(widget), metamargin );
|
||
|
MetaDataBase::setSpacing( TQT_TQOBJECT(widget), metaspacing );
|
||
15 years ago
|
} else {
|
||
|
l->setMargin( margin );
|
||
|
l->setSpacing( spacing );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
13 years ago
|
l->setAlignment( align );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
||
15 years ago
|
return l;
|
||
|
}
|
||
|
|
||
15 years ago
|
void WidgetFactory::deleteLayout( TQWidget *widget )
|
||
15 years ago
|
{
|
||
|
if ( !widget )
|
||
|
return;
|
||
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQTabWidget*>(widget) )
|
||
15 years ago
|
widget = ((TQTabWidget*)widget)->currentPage();
|
||
14 years ago
|
if ( ::tqqt_cast<TQWizard*>(widget) )
|
||
15 years ago
|
widget = ((TQWizard*)widget)->currentPage();
|
||
14 years ago
|
if ( ::tqqt_cast<TQMainWindow*>(widget) )
|
||
15 years ago
|
widget = ((TQMainWindow*)widget)->centralWidget();
|
||
14 years ago
|
if ( ::tqqt_cast<TQWidgetStack*>(widget) )
|
||
15 years ago
|
widget = ((TQWidgetStack*)widget)->visibleWidget();
|
||
14 years ago
|
if ( ::tqqt_cast<TQToolBox*>(widget) )
|
||
15 years ago
|
widget = ((TQToolBox*)widget)->currentItem();
|
||
13 years ago
|
delete widget->layout();
|
||
15 years ago
|
}
|
||
|
|
||
|
/*! Factory functions for creating a widget of the type \a className
|
||
14 years ago
|
as child of \a parent with the name \a name.
|
||
15 years ago
|
|
||
|
If \a init is TRUE, some initial default properties are set. This
|
||
|
has to be in sync with the initChangedProperties() function!
|
||
|
*/
|
||
|
|
||
14 years ago
|
TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *parent, const char *name, bool init,
|
||
15 years ago
|
const TQRect *r, Qt::Orientation orient )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( className == TQPUSHBUTTON_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
TQPushButton *b = 0;
|
||
15 years ago
|
if ( init ) {
|
||
14 years ago
|
b = new QDesignerPushButton( parent, name );
|
||
13 years ago
|
b->setText( TQString::fromLatin1( name ) );
|
||
15 years ago
|
} else {
|
||
14 years ago
|
b = new QDesignerPushButton( parent, name );
|
||
15 years ago
|
}
|
||
15 years ago
|
TQWidget *w = find_formwindow( b );
|
||
14 years ago
|
b->setAutoDefault( w && ::tqqt_cast<TQDialog*>(((FormWindow*)w)->mainContainer()) );
|
||
15 years ago
|
return b;
|
||
14 years ago
|
} else if ( className == TQTOOLBUTTON_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
if ( init ) {
|
||
14 years ago
|
QDesignerToolButton *tb = new QDesignerToolButton( parent, name );
|
||
|
if ( ::tqqt_cast<TQToolBox*>(widgetOfContainer(parent))) {
|
||
15 years ago
|
tb->setUsesTextLabel(TRUE);
|
||
|
tb->setTextLabel("...");
|
||
|
tb->setAutoRaise(TRUE);
|
||
15 years ago
|
tb->setTextPosition(TQToolButton::BesideIcon);
|
||
15 years ago
|
} else {
|
||
|
tb->setText( "..." );
|
||
|
}
|
||
|
return tb;
|
||
|
}
|
||
14 years ago
|
return new QDesignerToolButton( parent, name );
|
||
14 years ago
|
} else if ( className == TQCHECKBOX_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
if ( init ) {
|
||
14 years ago
|
QDesignerCheckBox *cb = new QDesignerCheckBox( parent, name );
|
||
13 years ago
|
cb->setText( TQString::fromLatin1( name ) );
|
||
15 years ago
|
return cb;
|
||
|
}
|
||
14 years ago
|
return new QDesignerCheckBox( parent, name );
|
||
14 years ago
|
} else if ( className == TQRADIOBUTTON_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
if ( init ) {
|
||
14 years ago
|
QDesignerRadioButton *rb = new QDesignerRadioButton( parent, name );
|
||
13 years ago
|
rb->setText( TQString::fromLatin1( name ) );
|
||
15 years ago
|
return rb;
|
||
|
}
|
||
14 years ago
|
return new QDesignerRadioButton( parent, name );
|
||
14 years ago
|
} else if ( className == TQGROUPBOX_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
if ( init )
|
||
13 years ago
|
return new TQGroupBox( TQString::fromLatin1( name ), parent, name );
|
||
14 years ago
|
return new TQGroupBox( parent, name );
|
||
14 years ago
|
} else if ( className == TQBUTTONGROUP_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
if ( init )
|
||
13 years ago
|
return new TQButtonGroup( TQString::fromLatin1( name ), parent, name );
|
||
14 years ago
|
return new TQButtonGroup( parent, name );
|
||
14 years ago
|
} else if ( className == TQICONVIEW_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
#if !defined(TQT_NO_ICONVIEW)
|
||
14 years ago
|
TQIconView* iv = new TQIconView( parent, name );
|
||
15 years ago
|
if ( init )
|
||
15 years ago
|
(void) new TQIconViewItem( iv, i18n( "New Item" ) );
|
||
15 years ago
|
return iv;
|
||
|
#else
|
||
|
return 0;
|
||
|
#endif
|
||
14 years ago
|
} else if ( className == TQTABLE_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
#if !defined(TQT_NO_TABLE)
|
||
15 years ago
|
if ( init )
|
||
14 years ago
|
return new TQTable( 3, 3, parent, name );
|
||
|
return new TQTable( parent, name );
|
||
15 years ago
|
#else
|
||
|
return 0;
|
||
|
#endif
|
||
14 years ago
|
#ifndef TQT_NO_SQL
|
||
14 years ago
|
} else if ( className == TQDATATABLE_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
return new TQDataTable( parent, name );
|
||
14 years ago
|
#endif //TQT_NO_SQL
|
||
14 years ago
|
} else if ( className == TQDATEEDIT_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
return new TQDateEdit( parent, name );
|
||
14 years ago
|
} else if ( className == TQTIMEEDIT_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
return new TQTimeEdit( parent, name );
|
||
14 years ago
|
} else if ( className == TQDATETIMEEDIT_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
return new TQDateTimeEdit( parent, name );
|
||
15 years ago
|
}
|
||
14 years ago
|
else if ( className == TQLISTBOX_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQListBox* lb = new TQListBox( parent, name );
|
||
15 years ago
|
if ( init ) {
|
||
|
lb->insertItem( i18n( "New Item" ) );
|
||
|
lb->setCurrentItem( 0 );
|
||
|
}
|
||
|
return lb;
|
||
14 years ago
|
} else if ( className == TQLISTVIEW_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQListView *lv = new TQListView( parent, name );
|
||
15 years ago
|
lv->setSorting( -1 );
|
||
|
if ( init ) {
|
||
|
lv->addColumn( i18n( "Column 1" ) );
|
||
15 years ago
|
lv->setCurrentItem( new TQListViewItem( lv, i18n( "New Item" ) ) );
|
||
15 years ago
|
}
|
||
|
return lv;
|
||
14 years ago
|
} else if ( className == TQLINEEDIT_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQLineEdit( parent, name );
|
||
14 years ago
|
else if ( className == TQSPINBOX_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQSpinBox( parent, name );
|
||
14 years ago
|
else if ( className == TQSPLITTER_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQSplitter( parent, name );
|
||
14 years ago
|
else if ( className == TQMULTILINEEDIT_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQMultiLineEdit( parent, name );
|
||
14 years ago
|
else if ( className == TQTEXTEDIT_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQTextEdit( parent, name );
|
||
14 years ago
|
else if ( className == TQLABEL_OBJECT_NAME_STRING || className == "TextLabel" ) {
|
||
14 years ago
|
QDesignerLabel *l = new QDesignerLabel( parent, name );
|
||
15 years ago
|
if ( init ) {
|
||
13 years ago
|
l->setText( TQString::fromLatin1( name ) );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(l), "text", TRUE );
|
||
15 years ago
|
}
|
||
|
return l;
|
||
|
} else if ( className == "PixmapLabel" ) {
|
||
14 years ago
|
QDesignerLabel *l = new QDesignerLabel( parent, name );
|
||
15 years ago
|
if ( init ) {
|
||
11 years ago
|
l->setPixmap( BarIcon( "designer_qtlogo.png", TDevDesignerPartFactory::instance() ) );
|
||
15 years ago
|
l->setScaledContents( TRUE );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(l), "pixmap", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(l), "scaledContents", TRUE );
|
||
15 years ago
|
}
|
||
|
return l;
|
||
14 years ago
|
} else if ( className == TQLAYOUTWIDGET_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQLayoutWidget( parent, name );
|
||
14 years ago
|
else if ( className == TQTABWIDGET_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQTabWidget *tw = new QDesignerTabWidget( parent, name );
|
||
15 years ago
|
if ( init ) {
|
||
14 years ago
|
FormWindow *fw = find_formwindow( parent );
|
||
14 years ago
|
TQWidget *w = fw ? new QDesignerWidget( fw, tw, "tab" ) : new TQWidget( tw, "tab" );
|
||
15 years ago
|
tw->addTab( w, i18n("Tab 1") );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(w) );
|
||
14 years ago
|
w = fw ? new QDesignerWidget( fw, tw, "tab" ) : new TQWidget( tw, "tab" );
|
||
15 years ago
|
tw->addTab( w, i18n("Tab 2") );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(tw) );
|
||
|
MetaDataBase::addEntry( TQT_TQOBJECT(w) );
|
||
15 years ago
|
}
|
||
|
return tw;
|
||
14 years ago
|
} else if ( className == TQWIDGETSTACK_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
QDesignerWidgetStack *ws = new QDesignerWidgetStack( parent, name );
|
||
15 years ago
|
if ( init ) {
|
||
14 years ago
|
FormWindow *fw = find_formwindow( parent );
|
||
14 years ago
|
TQWidget *w = fw ? new QDesignerWidget( fw, ws, "WStackPage" ) : new TQWidget( ws, "WStackPage" );
|
||
15 years ago
|
ws->insertPage( w );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(w) );
|
||
|
MetaDataBase::addEntry( TQT_TQOBJECT(ws) );
|
||
15 years ago
|
}
|
||
|
return ws;
|
||
14 years ago
|
} else if ( className == TQCOMBOBOX_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
return new TQComboBox( FALSE, parent, name );
|
||
14 years ago
|
} else if ( className == TQWIDGET_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
if ( parent &&
|
||
|
( ::tqqt_cast<FormWindow*>(parent) ||
|
||
|
::tqqt_cast<TQWizard*>(parent) ||
|
||
|
::tqqt_cast<TQTabWidget*>(parent) ||
|
||
|
::tqqt_cast<TQWidgetStack*>(parent) ||
|
||
|
::tqqt_cast<TQToolBox*>(parent) ||
|
||
|
::tqqt_cast<TQMainWindow*>(parent) ) ) {
|
||
|
FormWindow *fw = find_formwindow( parent );
|
||
15 years ago
|
if ( fw ) {
|
||
14 years ago
|
QDesignerWidget *dw = new QDesignerWidget( fw, parent, name );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(dw) );
|
||
15 years ago
|
return dw;
|
||
|
}
|
||
|
}
|
||
14 years ago
|
return new TQWidget( parent, name );
|
||
14 years ago
|
} else if ( className == TQDIALOG_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
TQDialog *dia = 0;
|
||
14 years ago
|
if ( ::tqqt_cast<FormWindow*>(parent) )
|
||
|
dia = new QDesignerDialog( (FormWindow*)parent, parent, name );
|
||
15 years ago
|
else
|
||
14 years ago
|
dia = new TQDialog( parent, name );
|
||
14 years ago
|
#if defined(TQT_NON_COMMERCIAL)
|
||
14 years ago
|
if ( ::tqqt_cast<MainWindow*>(parent) )
|
||
15 years ago
|
#else
|
||
14 years ago
|
if ( parent )
|
||
15 years ago
|
#endif
|
||
14 years ago
|
dia->reparent( parent, TQPoint( 0, 0 ), TRUE );
|
||
15 years ago
|
return dia;
|
||
14 years ago
|
} else if ( className == TQWIZARD_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQWizard *wiz = new QDesignerWizard( parent, name );
|
||
14 years ago
|
#if defined(TQT_NON_COMMERCIAL)
|
||
14 years ago
|
if ( ::tqqt_cast<MainWindow*>(parent) )
|
||
15 years ago
|
#else
|
||
14 years ago
|
if ( parent )
|
||
15 years ago
|
#endif
|
||
14 years ago
|
wiz->reparent( parent, TQPoint( 0, 0 ), TRUE );
|
||
|
if ( init && ::tqqt_cast<FormWindow*>(parent) ) {
|
||
|
QDesignerWidget *dw = new QDesignerWidget( (FormWindow*)parent, wiz, "WizardPage" );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(dw) );
|
||
15 years ago
|
wiz->addPage( dw, i18n( "Page" ) );
|
||
15 years ago
|
TQTimer::singleShot( 0, wiz, TQT_SLOT( next() ) );
|
||
15 years ago
|
}
|
||
|
return wiz;
|
||
|
} else if ( className == "Spacer" ) {
|
||
14 years ago
|
Spacer *s = new Spacer( parent, name );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(s) );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(s), "orientation", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(s), "sizeType", TRUE );
|
||
15 years ago
|
if ( !r )
|
||
|
return s;
|
||
|
if ( !r->isValid() || r->width() < 2 && r->height() < 2 )
|
||
|
s->setOrientation( orient );
|
||
|
else if ( r->width() < r->height() )
|
||
|
s->setOrientation( Qt::Vertical );
|
||
|
else
|
||
|
s->setOrientation( Qt::Horizontal );
|
||
|
return s;
|
||
14 years ago
|
} else if ( className == TQLCDNUMBER_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQLCDNumber( parent, name );
|
||
14 years ago
|
else if ( className == TQPROGRESSBAR_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQProgressBar( parent, name );
|
||
14 years ago
|
else if ( className == TQTEXTVIEW_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQTextView( parent, name );
|
||
14 years ago
|
else if ( className == TQTEXTBROWSER_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQTextBrowser( parent, name );
|
||
14 years ago
|
else if ( className == TQDIAL_OBJECT_NAME_STRING )
|
||
14 years ago
|
return new TQDial( parent, name );
|
||
14 years ago
|
else if ( className == TQSLIDER_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQSlider *s = new TQSlider( parent, name );
|
||
15 years ago
|
if ( !r )
|
||
|
return s;
|
||
|
if ( !r->isValid() || r->width() < 2 && r->height() < 2 )
|
||
|
s->setOrientation( orient );
|
||
|
else if ( r->width() > r->height() )
|
||
|
s->setOrientation( Qt::Horizontal );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(s) );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(s), "orientation", TRUE );
|
||
15 years ago
|
return s;
|
||
14 years ago
|
} else if ( className == TQSCROLLBAR_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQScrollBar *s = new TQScrollBar( parent, name );
|
||
15 years ago
|
if ( !r )
|
||
|
return s;
|
||
|
if ( !r->isValid() || r->width() < 2 && r->height() < 2 )
|
||
|
s->setOrientation( orient );
|
||
|
else if ( r->width() > r->height() )
|
||
|
s->setOrientation( Qt::Horizontal );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(s) );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(s), "orientation", TRUE );
|
||
15 years ago
|
return s;
|
||
14 years ago
|
} else if ( className == TQFRAME_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
if ( !init )
|
||
14 years ago
|
return new TQFrame( parent, name );
|
||
|
TQFrame *f = new TQFrame( parent, name );
|
||
15 years ago
|
f->setFrameStyle( TQFrame::StyledPanel | TQFrame::Raised );
|
||
15 years ago
|
return f;
|
||
|
} else if ( className == "Line" ) {
|
||
14 years ago
|
Line *l = new Line( parent, name );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(l), "orientation", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(l), "frameShadow", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(l), "frameShape", TRUE );
|
||
15 years ago
|
if ( !r )
|
||
|
return l;
|
||
|
if ( !r->isValid() || r->width() < 2 && r->height() < 2 )
|
||
|
l->setOrientation( orient );
|
||
|
else if ( r->width() < r->height() )
|
||
|
l->setOrientation( Qt::Vertical );
|
||
|
return l;
|
||
14 years ago
|
} else if ( className == TQMAINWINDOW_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQMainWindow *mw = new TQMainWindow( parent, name, 0 );
|
||
14 years ago
|
mw->setDockEnabled( TQt::DockMinimized, FALSE );
|
||
14 years ago
|
QDesignerWidget *dw = new QDesignerWidget( (FormWindow*)parent, mw, "central widget" );
|
||
15 years ago
|
mw->setDockMenuEnabled( FALSE );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(dw) );
|
||
15 years ago
|
mw->setCentralWidget( dw );
|
||
|
(void)mw->statusBar();
|
||
|
dw->show();
|
||
|
return mw;
|
||
14 years ago
|
} else if ( className == TQTOOLBOX_OBJECT_NAME_STRING ) {
|
||
15 years ago
|
if ( !init )
|
||
14 years ago
|
return new QDesignerToolBox( parent, name );
|
||
|
TQToolBox *tb = new QDesignerToolBox( parent, name );
|
||
|
FormWindow *fw = find_formwindow( parent );
|
||
14 years ago
|
TQWidget *w = fw ? new QDesignerWidget( fw, tb, "page1" ) :
|
||
15 years ago
|
new TQWidget( tb, "page1" );
|
||
15 years ago
|
tb->addItem( w, i18n("Page 1") );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(w) );
|
||
14 years ago
|
w = fw ? new QDesignerWidget( fw, tb, "page2" ) : new TQWidget( tb, "page2" );
|
||
15 years ago
|
tb->addItem( w, i18n("Page 2") );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(tb) );
|
||
|
MetaDataBase::addEntry( TQT_TQOBJECT(w) );
|
||
15 years ago
|
return tb;
|
||
|
}
|
||
14 years ago
|
#ifndef TQT_NO_SQL
|
||
14 years ago
|
else if ( className == TQDATABROWSER_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQWidget *w = new QDesignerDataBrowser( parent, name );
|
||
|
if ( parent )
|
||
|
w->reparent( parent, TQPoint( 0, 0 ), TRUE );
|
||
15 years ago
|
return w;
|
||
14 years ago
|
} else if ( className == TQDATAVIEW_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
TQWidget *w = new QDesignerDataView( parent, name );
|
||
|
if ( parent )
|
||
|
w->reparent( parent, TQPoint( 0, 0 ), TRUE );
|
||
15 years ago
|
return w;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
WidgetInterface *iface = 0;
|
||
|
widgetManager()->queryInterface( className, &iface );
|
||
|
if ( !iface )
|
||
|
return 0;
|
||
|
|
||
14 years ago
|
TQWidget *w = iface->create( className, parent, name );
|
||
14 years ago
|
#ifdef TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
if ( init && WidgetDatabase::isCustomPluginWidget( WidgetDatabase::idFromClassName( className ) ) ) {
|
||
14 years ago
|
TQWidgetContainerInterfacePrivate *iface2 = 0;
|
||
|
iface->queryInterface( IID_TQWidgetContainer, (TQUnknownInterface**)&iface2 );
|
||
15 years ago
|
if ( iface2 ) {
|
||
|
iface2->addPage( className, w, "Page", -1 );
|
||
|
iface2->release();
|
||
|
}
|
||
|
}
|
||
14 years ago
|
#endif // TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
iface->release();
|
||
|
return w;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
13 years ago
|
/*! Find out which type the layout of the widget is. Returns \c HBox,
|
||
|
\c VBox, \c Grid or \c NoLayout. \a layout points to this
|
||
|
TQWidget::layout() of \a w or to 0 after the function call.
|
||
15 years ago
|
*/
|
||
|
|
||
13 years ago
|
WidgetFactory::LayoutType WidgetFactory::layoutType( TQWidget *w, TQLayout *&layout )
|
||
15 years ago
|
{
|
||
13 years ago
|
layout = 0;
|
||
15 years ago
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQTabWidget*>(w) )
|
||
15 years ago
|
w = ((TQTabWidget*)w)->currentPage();
|
||
14 years ago
|
if ( ::tqqt_cast<TQWizard*>(w) )
|
||
15 years ago
|
w = ((TQWizard*)w)->currentPage();
|
||
14 years ago
|
if ( ::tqqt_cast<TQMainWindow*>(w) )
|
||
15 years ago
|
w = ((TQMainWindow*)w)->centralWidget();
|
||
14 years ago
|
if ( ::tqqt_cast<TQWidgetStack*>(w) )
|
||
15 years ago
|
w = ((TQWidgetStack*)w)->visibleWidget();
|
||
14 years ago
|
if ( ::tqqt_cast<TQToolBox*>(w) )
|
||
15 years ago
|
w = ((TQToolBox*)w)->currentItem();
|
||
15 years ago
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQSplitter*>(w) )
|
||
|
return ( (TQSplitter*)w )->orientation() ==Qt::Horizontal ? HBox : VBox;
|
||
15 years ago
|
|
||
13 years ago
|
if ( !w || !w->layout() )
|
||
15 years ago
|
return NoLayout;
|
||
13 years ago
|
TQLayout *lay = w->layout();
|
||
15 years ago
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQGroupBox*>(w) ) {
|
||
|
TQObjectList *l = TQT_TQOBJECT(lay)->queryList( TQLAYOUT_OBJECT_NAME_STRING );
|
||
15 years ago
|
if ( l && l->first() )
|
||
15 years ago
|
lay = (TQLayout*)l->first();
|
||
15 years ago
|
delete l;
|
||
|
}
|
||
13 years ago
|
layout = lay;
|
||
15 years ago
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQHBoxLayout*>(lay) )
|
||
15 years ago
|
return HBox;
|
||
14 years ago
|
else if ( ::tqqt_cast<TQVBoxLayout*>(lay) )
|
||
15 years ago
|
return VBox;
|
||
14 years ago
|
else if ( ::tqqt_cast<TQGridLayout*>(lay) )
|
||
15 years ago
|
return Grid;
|
||
|
return NoLayout;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
|
\overload
|
||
|
*/
|
||
13 years ago
|
WidgetFactory::LayoutType WidgetFactory::layoutType( TQLayout *layout )
|
||
15 years ago
|
{
|
||
13 years ago
|
if ( ::tqqt_cast<TQHBoxLayout*>(layout) )
|
||
15 years ago
|
return HBox;
|
||
13 years ago
|
else if ( ::tqqt_cast<TQVBoxLayout*>(layout) )
|
||
15 years ago
|
return VBox;
|
||
13 years ago
|
else if ( ::tqqt_cast<TQGridLayout*>(layout) )
|
||
15 years ago
|
return Grid;
|
||
|
return NoLayout;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
|
\overload
|
||
|
*/
|
||
14 years ago
|
WidgetFactory::LayoutType WidgetFactory::layoutType( TQWidget *w )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQLayout *l = 0;
|
||
14 years ago
|
return layoutType( w, l );
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
13 years ago
|
TQWidget *WidgetFactory::layoutParent( TQLayout *layout )
|
||
15 years ago
|
{
|
||
13 years ago
|
TQObject *o = TQT_TQOBJECT(layout);
|
||
15 years ago
|
while ( o ) {
|
||
|
if ( o->isWidgetType() )
|
||
15 years ago
|
return (TQWidget*)o;
|
||
14 years ago
|
o = o->parent();
|
||
15 years ago
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
13 years ago
|
/*! Returns the widget into which children should be inserted when \a
|
||
15 years ago
|
w is a container known to the designer.
|
||
|
|
||
|
Usually that is \a w itself, sometimes it is different (e.g. a
|
||
|
tabwidget is known to the designer as a container but the child
|
||
|
widgets should be inserted into the current page of the
|
||
|
tabwidget. So in this case this function returns the current page of
|
||
|
the tabwidget.)
|
||
|
*/
|
||
15 years ago
|
TQWidget* WidgetFactory::containerOfWidget( TQWidget *w )
|
||
15 years ago
|
{
|
||
|
if ( !w )
|
||
|
return w;
|
||
14 years ago
|
if ( ::tqqt_cast<TQTabWidget*>(w) )
|
||
15 years ago
|
return ((TQTabWidget*)w)->currentPage();
|
||
14 years ago
|
if ( ::tqqt_cast<TQWizard*>(w) )
|
||
15 years ago
|
return ((TQWizard*)w)->currentPage();
|
||
14 years ago
|
if ( ::tqqt_cast<TQWidgetStack*>(w) )
|
||
15 years ago
|
return ((TQWidgetStack*)w)->visibleWidget();
|
||
14 years ago
|
if ( ::tqqt_cast<TQToolBox*>(w) )
|
||
15 years ago
|
return ((TQToolBox*)w)->currentItem();
|
||
14 years ago
|
if ( ::tqqt_cast<TQMainWindow*>(w) )
|
||
15 years ago
|
return ((TQMainWindow*)w)->centralWidget();
|
||
14 years ago
|
#ifdef TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
if ( !WidgetDatabase::isCustomPluginWidget( WidgetDatabase::idFromClassName( classNameOf( w ) ) ) )
|
||
|
return w;
|
||
|
WidgetInterface *iface = 0;
|
||
|
widgetManager()->queryInterface( classNameOf( w ), &iface );
|
||
|
if ( !iface )
|
||
|
return w;
|
||
14 years ago
|
TQWidgetContainerInterfacePrivate *iface2 = 0;
|
||
|
iface->queryInterface( IID_TQWidgetContainer, (TQUnknownInterface**)&iface2 );
|
||
15 years ago
|
if ( !iface2 )
|
||
|
return w;
|
||
15 years ago
|
TQWidget *c = iface2->containerOfWidget( w->className(), w );
|
||
15 years ago
|
iface2->release();
|
||
|
iface->release();
|
||
|
if ( c )
|
||
|
return c;
|
||
14 years ago
|
#endif // TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
return w;
|
||
|
}
|
||
|
|
||
|
/*! Returns the actual designer widget of the container \a w. This is
|
||
14 years ago
|
normally \a w itself, but might be a parent or grand parent of \a w
|
||
15 years ago
|
(e.g. when working with a tabwidget and \a w is the container which
|
||
14 years ago
|
contains and layouts childs, but the actual widget known to the
|
||
14 years ago
|
designer is the tabwidget which is the parent of \a w. So this
|
||
15 years ago
|
function returns the tabwidget then.)
|
||
|
*/
|
||
|
|
||
15 years ago
|
TQWidget* WidgetFactory::widgetOfContainer( TQWidget *w )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( w && ::tqqt_cast<TQWidgetStack*>(w->parentWidget()) )
|
||
|
w = w->parentWidget();
|
||
|
if ( w->parentWidget() && w->parentWidget()->parentWidget() &&
|
||
|
w->parentWidget()->parentWidget()->parentWidget() &&
|
||
|
::tqqt_cast<TQToolBox*>(w->parentWidget()->parentWidget()->parentWidget()) )
|
||
|
return w->parentWidget()->parentWidget()->parentWidget();
|
||
15 years ago
|
while ( w ) {
|
||
14 years ago
|
int id = WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(w) ) );
|
||
15 years ago
|
if ( WidgetDatabase::isContainer( id ) ||
|
||
14 years ago
|
w && ::tqqt_cast<FormWindow*>(w->parentWidget()) )
|
||
15 years ago
|
return w;
|
||
14 years ago
|
w = w->parentWidget();
|
||
15 years ago
|
}
|
||
|
return w;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
|
Returns whether \a o is a passive interactor or not.
|
||
|
*/
|
||
|
|
||
|
bool WidgetFactory::lastWasAPassiveInteractor = FALSE;
|
||
15 years ago
|
TQGuardedPtr<TQObject> *WidgetFactory::lastPassiveInteractor = new TQGuardedPtr<TQObject>();
|
||
15 years ago
|
|
||
15 years ago
|
bool WidgetFactory::isPassiveInteractor( TQObject* o )
|
||
15 years ago
|
{
|
||
15 years ago
|
if ( lastPassiveInteractor && *lastPassiveInteractor && (TQObject*)(*lastPassiveInteractor) == o )
|
||
15 years ago
|
return lastWasAPassiveInteractor;
|
||
|
lastWasAPassiveInteractor = FALSE;
|
||
|
(*lastPassiveInteractor) = o;
|
||
15 years ago
|
if ( TQApplication::activePopupWidget() ) // if a popup is open, we have to make sure that this one is closed, else X might do funny things
|
||
15 years ago
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQTabBar*>(o) )
|
||
15 years ago
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
14 years ago
|
else if ( ::tqqt_cast<TQSizeGrip*>(o) )
|
||
15 years ago
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
14 years ago
|
else if ( ::tqqt_cast<TQButton*>(o) &&
|
||
14 years ago
|
( ::tqqt_cast<TQTabBar*>(o->parent()) || ::tqqt_cast<TQToolBox*>(o->parent()) ) )
|
||
15 years ago
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
14 years ago
|
else if ( ::tqqt_cast<TQPushButton*>(o) && ::tqqt_cast<TQWizard*>(o->parent()) )
|
||
15 years ago
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
14 years ago
|
else if ( ::tqqt_cast<TQMenuBar*>(o) && ::tqqt_cast<TQMainWindow*>(o->parent()) )
|
||
15 years ago
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
14 years ago
|
// else if ( ::tqqt_cast<TQDockWindowHandle*>(o) )
|
||
|
else if ( o->inherits( TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING ) )
|
||
15 years ago
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
14 years ago
|
// else if ( ::tqqt_cast<TQHideDock*>(o) )
|
||
|
else if ( o->inherits( TQHIDEDOCK_OBJECT_NAME_STRING ) )
|
||
15 years ago
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
|
else if ( qstrcmp( o->name(), "designer_wizardstack_button" ) == 0 )
|
||
|
return ( lastWasAPassiveInteractor = TRUE );
|
||
14 years ago
|
#ifdef TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
if ( !o->isWidgetType() )
|
||
|
return ( lastWasAPassiveInteractor = FALSE );
|
||
|
WidgetInterface *iface = 0;
|
||
15 years ago
|
TQWidget *w = (TQWidget*)o;
|
||
14 years ago
|
while ( !iface && w && !::tqqt_cast<FormWindow*>(w) ) {
|
||
15 years ago
|
widgetManager()->queryInterface( classNameOf( w ), &iface );
|
||
14 years ago
|
w = w->parentWidget();
|
||
15 years ago
|
}
|
||
|
if ( !iface )
|
||
|
return ( lastWasAPassiveInteractor = FALSE );
|
||
14 years ago
|
TQWidgetContainerInterfacePrivate *iface2 = 0;
|
||
|
iface->queryInterface( IID_TQWidgetContainer, (TQUnknownInterface**)&iface2 );
|
||
15 years ago
|
if ( !iface2 )
|
||
|
return ( lastWasAPassiveInteractor = FALSE );
|
||
15 years ago
|
TQWidget *fw = MainWindow::self->isAFormWindowChild( (TQWidget*)o );
|
||
15 years ago
|
if ( !fw )
|
||
|
return ( lastWasAPassiveInteractor = FALSE );
|
||
15 years ago
|
TQWidget *dw = ( (FormWindow*)fw )->designerWidget( (TQWidget*)o );
|
||
15 years ago
|
if ( !dw )
|
||
|
return ( lastWasAPassiveInteractor = FALSE );
|
||
15 years ago
|
lastWasAPassiveInteractor = iface2->isPassiveInteractor( dw->className(), (TQWidget*)o );
|
||
15 years ago
|
iface2->release();
|
||
|
iface->release();
|
||
14 years ago
|
#endif // TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
return lastWasAPassiveInteractor;
|
||
|
}
|
||
|
|
||
|
|
||
|
/*!
|
||
|
Returns the class name of object \a o that should be used for externally (i.e. for saving)
|
||
|
*/
|
||
15 years ago
|
const char* WidgetFactory::classNameOf( TQObject* o )
|
||
15 years ago
|
{
|
||
|
if ( o->isA( "PropertyObject" ) )
|
||
|
return o->className();
|
||
|
if (WidgetDatabase::isCustomPluginWidget(WidgetDatabase::idFromClassName(o->className())))
|
||
|
return o->className();
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerTabWidget*>(o) )
|
||
14 years ago
|
return TQTABWIDGET_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerWidgetStack*>(o) )
|
||
14 years ago
|
return TQWIDGETSTACK_OBJECT_NAME_STRING;
|
||
|
else if ( ::tqqt_cast<TQWidgetStack*>(o) )
|
||
|
return "TQWeDoNotWantToBreakTabWidget";
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerDialog*>(o) )
|
||
14 years ago
|
return TQDIALOG_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerWidget*>(o) )
|
||
14 years ago
|
return TQWIDGET_OBJECT_NAME_STRING;
|
||
15 years ago
|
else if ( o->inherits( "CustomWidget" ) )
|
||
|
return ( (CustomWidget*)o )->realClassName().latin1();
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerLabel*>(o) )
|
||
14 years ago
|
return TQLABEL_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerWizard*>(o) )
|
||
14 years ago
|
return TQWIZARD_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerPushButton*>(o) )
|
||
14 years ago
|
return TQPUSHBUTTON_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerToolButton*>(o) )
|
||
14 years ago
|
return TQTOOLBUTTON_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerRadioButton*>(o) )
|
||
14 years ago
|
return TQRADIOBUTTON_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerCheckBox*>(o) )
|
||
14 years ago
|
return TQCHECKBOX_OBJECT_NAME_STRING;
|
||
|
else if ( ::tqqt_cast<MenuBarEditor*>(o) )
|
||
|
return TQMENUBAR_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerToolBar*>(o) )
|
||
14 years ago
|
return TQTOOLBAR_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerAction*>(o) )
|
||
14 years ago
|
return TQACTION_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerActionGroup*>(o) )
|
||
14 years ago
|
return TQACTIONGROUP_OBJECT_NAME_STRING;
|
||
|
else if ( ::tqqt_cast<PopupMenuEditor*>(o) )
|
||
|
return TQPOPUPMENU_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerToolBox*>(o) )
|
||
14 years ago
|
return TQTOOLBOX_OBJECT_NAME_STRING;
|
||
|
#ifndef TQT_NO_SQL
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerDataBrowser*>(o) )
|
||
14 years ago
|
return TQDATABROWSER_OBJECT_NAME_STRING;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerDataView*>(o) )
|
||
14 years ago
|
return TQDATAVIEW_OBJECT_NAME_STRING;
|
||
15 years ago
|
#endif
|
||
|
return o->className();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString WidgetFactory::defaultSignal( TQObject *w )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( ::tqqt_cast<TQRadioButton*>(w) || ::tqqt_cast<TQCheckBox*>(w) )
|
||
15 years ago
|
return "toggled";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQButton*>(w) || ::tqqt_cast<TQButtonGroup*>(w) )
|
||
15 years ago
|
return "clicked";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQTextBrowser*>(w) )
|
||
15 years ago
|
return "linkClicked";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQLineEdit*>(w) || ::tqqt_cast<TQTextEdit*>(w) )
|
||
15 years ago
|
return "textChanged";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQListView*>(w) || ::tqqt_cast<TQIconView*>(w) ||
|
||
|
::tqqt_cast<TQListBox*>(w) || ::tqqt_cast<TQTable*>(w) )
|
||
15 years ago
|
return "selectionChanged";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQTabWidget*>(w) )
|
||
15 years ago
|
return "selected";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQToolBox*>(w) )
|
||
15 years ago
|
return "currentChanged";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQWidgetStack*>(w) )
|
||
15 years ago
|
return "aboutToShow";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQSpinBox*>(w) || ::tqqt_cast<TQSlider*>(w) ||
|
||
|
::tqqt_cast<TQScrollBar*>(w) || ::tqqt_cast<TQDateEdit*>(w) ||
|
||
|
::tqqt_cast<TQTimeEdit*>(w) || ::tqqt_cast<TQDateTimeEdit*>(w) ||
|
||
|
::tqqt_cast<TQDial*>(w) )
|
||
15 years ago
|
return "valueChanged";
|
||
14 years ago
|
else if ( ::tqqt_cast<TQComboBox*>(w) )
|
||
15 years ago
|
return "activated";
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
|
||
|
/*! As some properties are set by default when creating a widget this
|
||
|
functions markes this properties as changed. Has to be in sync with
|
||
|
createWidget()!
|
||
|
*/
|
||
|
|
||
15 years ago
|
void WidgetFactory::initChangedProperties( TQObject *o )
|
||
15 years ago
|
{
|
||
|
if ( MainWindow::self && MainWindow::self->currProject() &&
|
||
|
MainWindow::self->currProject()->fakeFormFileFor( o ) )
|
||
|
return;
|
||
|
MetaDataBase::setPropertyChanged( o, "name", TRUE );
|
||
14 years ago
|
if ( !::tqqt_cast<QDesignerToolBar*>(o) && !::tqqt_cast<MenuBarEditor*>(o) )
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "geometry", TRUE );
|
||
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQPushButton*>(o) ||
|
||
|
::tqqt_cast<TQRadioButton*>(o) ||
|
||
|
::tqqt_cast<TQCheckBox*>(o) ||
|
||
|
::tqqt_cast<TQToolButton*>(o) ) {
|
||
14 years ago
|
if (::tqqt_cast<TQToolButton*>(o) && ::tqqt_cast<TQToolBox*>(widgetOfContainer((TQWidget*)o->parent()))) {
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "usesTextLabel", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "textLabel", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "autoRaise", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "textPosition", TRUE );
|
||
|
} else {
|
||
|
MetaDataBase::setPropertyChanged( o, "text", TRUE );
|
||
|
}
|
||
|
}
|
||
14 years ago
|
else if ( ::tqqt_cast<TQGroupBox*>(o) )
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "title", TRUE );
|
||
14 years ago
|
else if ( o->isA( TQFRAME_OBJECT_NAME_STRING ) ) {
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "frameShadow", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "frameShape", TRUE );
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQTabWidget*>(o) || ::tqqt_cast<TQWizard*>(o) ) {
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "pageTitle", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "pageName", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "currentPage", TRUE );
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQWidgetStack*>(o) ) {
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "currentPage", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "pageName", TRUE );
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQToolBox*>(o) ) {
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "currentIndex", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "itemName", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "itemLabel", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "itemIconSet", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "itemToolTip", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "itemBackgroundMode", TRUE );
|
||
14 years ago
|
#ifndef TQT_NO_TABLE
|
||
|
} else if ( ::tqqt_cast<TQTable*>(o) ) {
|
||
|
# ifndef TQT_NO_SQL
|
||
|
if (!::tqqt_cast<TQDataTable*>(o) )
|
||
15 years ago
|
# endif
|
||
|
{
|
||
|
MetaDataBase::setPropertyChanged( o, "numRows", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "numCols", TRUE );
|
||
15 years ago
|
TQTable *t = (TQTable*)o;
|
||
15 years ago
|
for ( int i = 0; i < 3; ++i ) {
|
||
15 years ago
|
t->horizontalHeader()->setLabel( i, TQString::number( i + 1 ) );
|
||
|
t->verticalHeader()->setLabel( i, TQString::number( i + 1 ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
#endif
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQSplitter*>(o) ) {
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "orientation", TRUE );
|
||
14 years ago
|
} else if ( ::tqqt_cast<QDesignerToolBar*>(o) ) {
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "label", TRUE );
|
||
14 years ago
|
} else if ( ::tqqt_cast<MenuBarEditor*>(o) ) {
|
||
15 years ago
|
MetaDataBase::setPropertyChanged( o, "itemName", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "itemNumber", TRUE );
|
||
|
MetaDataBase::setPropertyChanged( o, "itemText", TRUE );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
bool WidgetFactory::hasSpecialEditor( int id, TQObject *editorWidget )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString className = WidgetDatabase::className( id );
|
||
15 years ago
|
|
||
14 years ago
|
if ( className.contains( "ListBox" ) )
|
||
15 years ago
|
return TRUE;
|
||
14 years ago
|
if ( className.contains( "ComboBox" ) )
|
||
15 years ago
|
return TRUE;
|
||
14 years ago
|
if ( className.contains( "ListView" ) )
|
||
15 years ago
|
return TRUE;
|
||
14 years ago
|
if ( className.contains( "IconView" ) )
|
||
15 years ago
|
return TRUE;
|
||
14 years ago
|
if ( className == TQTEXTEDIT_OBJECT_NAME_STRING || className == TQMULTILINEEDIT_OBJECT_NAME_STRING )
|
||
15 years ago
|
return TRUE;
|
||
14 years ago
|
if ( ::tqqt_cast<TQTable*>(editorWidget) != 0 )
|
||
15 years ago
|
return TRUE;
|
||
|
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
15 years ago
|
bool WidgetFactory::hasItems( int id, TQObject *editorWidget )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString className = WidgetDatabase::className( id );
|
||
15 years ago
|
|
||
14 years ago
|
if ( className.contains( "ListBox" ) || className.contains( "ListView" ) ||
|
||
|
className.contains( "IconView" ) || className.contains( "ComboBox" ) ||
|
||
14 years ago
|
::tqqt_cast<TQTable*>(editorWidget) != 0 )
|
||
15 years ago
|
return TRUE;
|
||
|
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
14 years ago
|
void WidgetFactory::editWidget( int id, TQWidget *parent, TQWidget *editWidget, FormWindow *fw )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString className = WidgetDatabase::className( id );
|
||
15 years ago
|
|
||
14 years ago
|
if ( className.contains( "ListBox" ) ) {
|
||
14 years ago
|
if ( !::tqqt_cast<TQListBox*>(editWidget) )
|
||
15 years ago
|
return;
|
||
14 years ago
|
ListBoxEditor *e = new ListBoxEditor( parent, editWidget, fw );
|
||
15 years ago
|
e->exec();
|
||
|
delete e;
|
||
|
return;
|
||
|
}
|
||
|
|
||
14 years ago
|
if ( className.contains( "ComboBox" ) ) {
|
||
14 years ago
|
if ( !::tqqt_cast<TQComboBox*>(editWidget) )
|
||
15 years ago
|
return;
|
||
15 years ago
|
TQComboBox *cb = (TQComboBox*)editWidget;
|
||
14 years ago
|
ListBoxEditor *e = new ListBoxEditor( parent, cb->listBox(), fw );
|
||
15 years ago
|
e->exec();
|
||
|
delete e;
|
||
|
cb->update();
|
||
|
return;
|
||
|
}
|
||
|
|
||
14 years ago
|
if ( className.contains( "ListView" ) ) {
|
||
14 years ago
|
if ( !::tqqt_cast<TQListView*>(editWidget) )
|
||
15 years ago
|
return;
|
||
15 years ago
|
TQListView *lv = (TQListView*)editWidget;
|
||
14 years ago
|
ListViewEditor *e = new ListViewEditor( parent, lv, fw );
|
||
15 years ago
|
e->exec();
|
||
|
delete e;
|
||
|
return;
|
||
|
}
|
||
|
|
||
14 years ago
|
if ( className.contains( "IconView" ) ) {
|
||
14 years ago
|
if ( !::tqqt_cast<TQIconView*>(editWidget) )
|
||
15 years ago
|
return;
|
||
14 years ago
|
IconViewEditor *e = new IconViewEditor( parent, editWidget, fw );
|
||
15 years ago
|
e->exec();
|
||
|
delete e;
|
||
|
return;
|
||
|
}
|
||
|
|
||
14 years ago
|
if ( className == TQMULTILINEEDIT_OBJECT_NAME_STRING || className == TQTEXTEDIT_OBJECT_NAME_STRING ) {
|
||
14 years ago
|
MultiLineEditor *e = new MultiLineEditor( FALSE, TRUE, parent, editWidget, fw );
|
||
15 years ago
|
e->exec();
|
||
|
delete e;
|
||
|
return;
|
||
|
}
|
||
14 years ago
|
#ifndef TQT_NO_TABLE
|
||
|
if (::tqqt_cast<TQTable*>(editWidget) != 0) {
|
||
14 years ago
|
TableEditor *e = new TableEditor( parent, editWidget, fw );
|
||
15 years ago
|
e->exec();
|
||
|
delete e;
|
||
|
return;
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
|
||
15 years ago
|
bool WidgetFactory::canResetProperty( TQObject *w, const TQString &propName )
|
||
15 years ago
|
{
|
||
|
if ( propName == "name" || propName == "geometry" )
|
||
|
return FALSE;
|
||
14 years ago
|
TQStringList l = *changedProperties->find( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( w ) ) );
|
||
|
return l.findIndex( propName ) == -1;
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
bool WidgetFactory::resetProperty( TQObject *w, const TQString &propName )
|
||
15 years ago
|
{
|
||
13 years ago
|
const TQMetaProperty *p = w->metaObject()->property( w->metaObject()->
|
||
14 years ago
|
findProperty( propName, TRUE ), TRUE );
|
||
15 years ago
|
if (!p )
|
||
|
return FALSE;
|
||
|
return p->reset( w );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQVariant WidgetFactory::defaultValue( TQObject *w, const TQString &propName )
|
||
15 years ago
|
{
|
||
|
if ( propName == "wordwrap" ) {
|
||
13 years ago
|
int v = defaultValue( w, "alignment" ).toInt();
|
||
15 years ago
|
return TQVariant( ( v & WordBreak ) == WordBreak, 0 );
|
||
15 years ago
|
} else if ( propName == "toolTip" || propName == "whatsThis" ) {
|
||
13 years ago
|
return TQVariant( TQString::fromLatin1( "" ) );
|
||
15 years ago
|
} else if ( w->inherits( "CustomWidget" ) ) {
|
||
15 years ago
|
return TQVariant();
|
||
15 years ago
|
} else if ( propName == "frameworkCode" ) {
|
||
15 years ago
|
return TQVariant( TRUE, 0 );
|
||
14 years ago
|
} else if ( propName == "layoutMargin" || propName == "layoutSpacing" ) {
|
||
15 years ago
|
return TQVariant( -1 );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
return *( *defaultProperties->find( WidgetDatabase::idFromClassName( classNameOf( w ) ) ) ).find( propName );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQString WidgetFactory::defaultCurrentItem( TQObject *w, const TQString &propName )
|
||
15 years ago
|
{
|
||
13 years ago
|
const TQMetaProperty *p = w->metaObject()->
|
||
|
property( w->metaObject()->findProperty( propName, TRUE ), TRUE );
|
||
15 years ago
|
if ( !p ) {
|
||
13 years ago
|
int v = defaultValue( w, "alignment" ).toInt();
|
||
15 years ago
|
if ( propName == "hAlign" ) {
|
||
|
if ( ( v & AlignAuto ) == AlignAuto )
|
||
|
return "AlignAuto";
|
||
|
if ( ( v & AlignLeft ) == AlignLeft )
|
||
|
return "AlignLeft";
|
||
|
if ( ( v & AlignCenter ) == AlignCenter || ( v & AlignHCenter ) == AlignHCenter )
|
||
|
return "AlignHCenter";
|
||
|
if ( ( v & AlignRight ) == AlignRight )
|
||
|
return "AlignRight";
|
||
|
if ( ( v & AlignJustify ) == AlignJustify )
|
||
|
return "AlignJustify";
|
||
|
} else if ( propName == "vAlign" ) {
|
||
|
if ( ( v & AlignTop ) == AlignTop )
|
||
|
return "AlignTop";
|
||
|
if ( ( v & AlignCenter ) == AlignCenter || ( v & AlignVCenter ) == AlignVCenter )
|
||
|
return "AlignVCenter";
|
||
|
if ( ( v & AlignBottom ) == AlignBottom )
|
||
|
return "AlignBottom";
|
||
|
} else if ( propName == "resizeMode" ) {
|
||
|
return "Auto";
|
||
|
}
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
|
||
|
}
|
||
|
return p->valueToKey( defaultValue( w, propName ).toInt() );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQWidget *WidgetFactory::createCustomWidget( TQWidget *parent, const char *name, MetaDataBase::CustomWidget *w )
|
||
15 years ago
|
{
|
||
|
if ( !w )
|
||
|
return 0;
|
||
14 years ago
|
return new CustomWidget( parent, name, w );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQVariant WidgetFactory::property( TQObject *w, const char *name )
|
||
15 years ago
|
{
|
||
13 years ago
|
int id = w->metaObject()->findProperty( name, TRUE );
|
||
|
const TQMetaProperty* p = w->metaObject()->property( id, TRUE );
|
||
15 years ago
|
if ( !p || !p->isValid() )
|
||
|
return MetaDataBase::fakeProperty( w, name );
|
||
|
return w->property( name );
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerLabel::updateBuddy()
|
||
15 years ago
|
{
|
||
|
|
||
|
if ( myBuddy.isEmpty() )
|
||
|
return;
|
||
|
|
||
13 years ago
|
TQObjectList *l = topLevelWidget()->queryList( TQWIDGET_OBJECT_NAME_STRING, myBuddy, FALSE, TRUE );
|
||
15 years ago
|
if ( !l || !l->first() ) {
|
||
|
delete l;
|
||
|
return;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQLabel::setBuddy( (TQWidget*)l->first() );
|
||
15 years ago
|
delete l;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void QDesignerWidget::resizeEvent( TQResizeEvent* e)
|
||
15 years ago
|
{
|
||
|
if ( need_frame ) {
|
||
15 years ago
|
TQPainter p(this);
|
||
15 years ago
|
p.setPen( backgroundColor() );
|
||
15 years ago
|
p.drawRect( TQRect( TQPoint(0,0), e->oldSize() ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerWidget::paintEvent( TQPaintEvent *e )
|
||
15 years ago
|
{
|
||
|
if ( need_frame ) {
|
||
15 years ago
|
TQPainter p(this);
|
||
15 years ago
|
p.setPen( backgroundColor().dark() );
|
||
|
p.drawRect( rect() );
|
||
|
}
|
||
|
formwindow->paintGrid( this, e );
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerDialog::paintEvent( TQPaintEvent *e )
|
||
15 years ago
|
{
|
||
|
formwindow->paintGrid( this, e );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQSizePolicy TQLayoutWidget::sizePolicy() const
|
||
15 years ago
|
{
|
||
|
return sp;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool TQLayoutWidget::event( TQEvent *e )
|
||
15 years ago
|
{
|
||
15 years ago
|
if ( e && ( e->type() == TQEvent::ChildInserted ||
|
||
|
e->type() == TQEvent::ChildRemoved ||
|
||
|
e->type() == TQEvent::LayoutHint ||
|
||
|
e->type() == TQEvent::Reparent ) )
|
||
15 years ago
|
updateSizePolicy();
|
||
15 years ago
|
return TQWidget::event( e );
|
||
15 years ago
|
}
|
||
|
|
||
|
/*
|
||
14 years ago
|
This function must be called on TQLayoutWidget creation and whenever
|
||
13 years ago
|
the TQLayoutWidget's parent layout changes (e.g., from a TQHBoxLayout
|
||
14 years ago
|
to a TQVBoxLayout), because of the (illogical) way layouting works.
|
||
15 years ago
|
*/
|
||
14 years ago
|
void TQLayoutWidget::updateSizePolicy()
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( childrenListObject().isEmpty() || childrenListObject().count() == 0 ) {
|
||
13 years ago
|
sp = TQWidget::sizePolicy();
|
||
15 years ago
|
return;
|
||
|
}
|
||
|
|
||
|
/*
|
||
15 years ago
|
TQSizePolicy::MayShrink & friends are private. Here we assume the
|
||
15 years ago
|
following:
|
||
|
|
||
|
Fixed = 0
|
||
|
Maximum = MayShrink
|
||
|
Minimum = MayGrow
|
||
|
Preferred = MayShrink | MayGrow
|
||
|
*/
|
||
|
|
||
15 years ago
|
int ht = (int) TQSizePolicy::Preferred;
|
||
|
int vt = (int) TQSizePolicy::Preferred;
|
||
15 years ago
|
|
||
13 years ago
|
if ( layout() ) {
|
||
15 years ago
|
/*
|
||
13 years ago
|
parentLayout is set to the parent layout if there is one and if it is
|
||
14 years ago
|
top level, in which case layouting is illogical.
|
||
15 years ago
|
*/
|
||
14 years ago
|
TQLayout *parentLayout = 0;
|
||
14 years ago
|
if ( parent() && parent()->isWidgetType() ) {
|
||
13 years ago
|
parentLayout = ((TQWidget *)parent())->layout();
|
||
14 years ago
|
if ( parentLayout &&
|
||
|
::tqqt_cast<TQLayoutWidget*>(parentLayout->mainWidget()) )
|
||
|
parentLayout = 0;
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
TQObjectListIt it( childrenListObject() );
|
||
15 years ago
|
TQObject *o;
|
||
15 years ago
|
|
||
13 years ago
|
if ( ::tqqt_cast<TQVBoxLayout*>(layout()) ) {
|
||
14 years ago
|
if ( ::tqqt_cast<TQHBoxLayout*>(parentLayout) )
|
||
15 years ago
|
vt = TQSizePolicy::Minimum;
|
||
15 years ago
|
else
|
||
15 years ago
|
vt = TQSizePolicy::Fixed;
|
||
15 years ago
|
|
||
|
while ( ( o = it.current() ) ) {
|
||
|
++it;
|
||
15 years ago
|
if ( !o->isWidgetType() || ( (TQWidget*)o )->testWState( WState_ForceHide ) )
|
||
15 years ago
|
continue;
|
||
15 years ago
|
TQWidget *w = (TQWidget*)o;
|
||
15 years ago
|
|
||
13 years ago
|
if ( !w->sizePolicy().mayGrowHorizontally() )
|
||
15 years ago
|
ht &= ~TQSizePolicy::Minimum;
|
||
13 years ago
|
if ( !w->sizePolicy().mayShrinkHorizontally() )
|
||
15 years ago
|
ht &= ~TQSizePolicy::Maximum;
|
||
13 years ago
|
if ( w->sizePolicy().mayGrowVertically() )
|
||
15 years ago
|
vt |= TQSizePolicy::Minimum;
|
||
13 years ago
|
if ( w->sizePolicy().mayShrinkVertically() )
|
||
15 years ago
|
vt |= TQSizePolicy::Maximum;
|
||
15 years ago
|
}
|
||
13 years ago
|
} else if ( ::tqqt_cast<TQHBoxLayout*>(layout()) ) {
|
||
14 years ago
|
if ( ::tqqt_cast<TQVBoxLayout*>(parentLayout) )
|
||
15 years ago
|
ht = TQSizePolicy::Minimum;
|
||
15 years ago
|
else
|
||
15 years ago
|
ht = TQSizePolicy::Fixed;
|
||
15 years ago
|
|
||
|
while ( ( o = it.current() ) ) {
|
||
|
++it;
|
||
15 years ago
|
if ( !o->isWidgetType() || ( (TQWidget*)o )->testWState( WState_ForceHide ) )
|
||
15 years ago
|
continue;
|
||
15 years ago
|
TQWidget *w = (TQWidget*)o;
|
||
15 years ago
|
|
||
13 years ago
|
if ( w->sizePolicy().mayGrowHorizontally() )
|
||
15 years ago
|
ht |= TQSizePolicy::Minimum;
|
||
13 years ago
|
if ( w->sizePolicy().mayShrinkHorizontally() )
|
||
15 years ago
|
ht |= TQSizePolicy::Maximum;
|
||
13 years ago
|
if ( !w->sizePolicy().mayGrowVertically() )
|
||
15 years ago
|
vt &= ~TQSizePolicy::Minimum;
|
||
13 years ago
|
if ( !w->sizePolicy().mayShrinkVertically() )
|
||
15 years ago
|
vt &= ~TQSizePolicy::Maximum;
|
||
15 years ago
|
}
|
||
13 years ago
|
} else if ( ::tqqt_cast<TQGridLayout*>(layout()) ) {
|
||
15 years ago
|
ht = TQSizePolicy::Fixed;
|
||
|
vt = TQSizePolicy::Fixed;
|
||
14 years ago
|
if ( parentLayout ) {
|
||
|
if ( ::tqqt_cast<TQVBoxLayout*>(parentLayout) )
|
||
15 years ago
|
ht = TQSizePolicy::Minimum;
|
||
14 years ago
|
else if ( ::tqqt_cast<TQHBoxLayout*>(parentLayout) )
|
||
15 years ago
|
vt = TQSizePolicy::Minimum;
|
||
15 years ago
|
}
|
||
|
|
||
|
while ( ( o = it.current() ) ) {
|
||
|
++it;
|
||
15 years ago
|
if ( !o->isWidgetType() || ( (TQWidget*)o )->testWState( WState_ForceHide ) )
|
||
15 years ago
|
continue;
|
||
15 years ago
|
TQWidget *w = (TQWidget*)o;
|
||
15 years ago
|
|
||
13 years ago
|
if ( w->sizePolicy().mayGrowHorizontally() )
|
||
15 years ago
|
ht |= TQSizePolicy::Minimum;
|
||
13 years ago
|
if ( w->sizePolicy().mayShrinkHorizontally() )
|
||
15 years ago
|
ht |= TQSizePolicy::Maximum;
|
||
13 years ago
|
if ( w->sizePolicy().mayGrowVertically() )
|
||
15 years ago
|
vt |= TQSizePolicy::Minimum;
|
||
13 years ago
|
if ( w->sizePolicy().mayShrinkVertically() )
|
||
15 years ago
|
vt |= TQSizePolicy::Maximum;
|
||
15 years ago
|
}
|
||
|
}
|
||
14 years ago
|
#ifdef USE_QT4
|
||
13 years ago
|
if ( layout()->expanding() & TQSizePolicy::Horizontally )
|
||
14 years ago
|
#else // USE_QT4
|
||
13 years ago
|
if ( layout()->expanding() & TQSizePolicy::Horizontally )
|
||
14 years ago
|
#endif // USE_QT4
|
||
15 years ago
|
ht = TQSizePolicy::Expanding;
|
||
14 years ago
|
#ifdef USE_QT4
|
||
13 years ago
|
if ( layout()->expanding() & TQSizePolicy::Vertically )
|
||
14 years ago
|
#else // USE_QT4
|
||
13 years ago
|
if ( layout()->expanding() & TQSizePolicy::Vertically )
|
||
14 years ago
|
#endif // USE_QT4
|
||
15 years ago
|
vt = TQSizePolicy::Expanding;
|
||
15 years ago
|
|
||
13 years ago
|
layout()->invalidate();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
sp = TQSizePolicy( (TQSizePolicy::SizeType) ht, (TQSizePolicy::SizeType) vt );
|
||
15 years ago
|
updateGeometry();
|
||
|
}
|
||
|
|
||
15 years ago
|
void CustomWidget::paintEvent( TQPaintEvent *e )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( ::tqqt_cast<FormWindow*>(parentWidget()) ) {
|
||
|
( (FormWindow*)parentWidget() )->paintGrid( this, e );
|
||
15 years ago
|
} else {
|
||
15 years ago
|
TQPainter p( this );
|
||
13 years ago
|
p.fillRect( rect(), colorGroup().dark() );
|
||
|
p.setPen( colorGroup().light() );
|
||
14 years ago
|
p.drawText( 2, 2, width() - 4, height() - 4, TQt::AlignAuto | TQt::AlignTop, cusw->className );
|
||
15 years ago
|
p.drawPixmap( ( width() - cusw->pixmap->width() ) / 2,
|
||
|
( height() - cusw->pixmap->height() ) / 2,
|
||
|
*cusw->pixmap );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
CustomWidgetFactory::CustomWidgetFactory()
|
||
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
TQWidget *CustomWidgetFactory::createWidget( const TQString &className, TQWidget *parent, const char *name ) const
|
||
15 years ago
|
{
|
||
|
MetaDataBase::CustomWidget *w = MetaDataBase::customWidget( WidgetDatabase::idFromClassName( className ) );
|
||
|
if ( !w )
|
||
|
return 0;
|
||
14 years ago
|
return WidgetFactory::createCustomWidget( parent, name, w );
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
14 years ago
|
QDesignerToolBox::QDesignerToolBox( TQWidget *parent, const char *name )
|
||
|
: TQToolBox( parent, name )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString QDesignerToolBox::itemLabel() const
|
||
15 years ago
|
{
|
||
15 years ago
|
return TQToolBox::itemLabel( currentIndex() );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void QDesignerToolBox::setItemLabel( const TQString &l )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQToolBox::setItemLabel( currentIndex(), l );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
TQCString QDesignerToolBox::itemName() const
|
||
15 years ago
|
{
|
||
|
return currentItem() ? currentItem()->name() : 0;
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerToolBox::setItemName( const TQCString &n )
|
||
15 years ago
|
{
|
||
|
if (currentItem())
|
||
|
currentItem()->setName( n );
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
TQt::BackgroundMode QDesignerToolBox::itemBackgroundMode() const
|
||
15 years ago
|
{
|
||
|
return (item(0) ? item(0)->backgroundMode() : PaletteBackground);
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerToolBox::setItemBackgroundMode( BackgroundMode bmode )
|
||
15 years ago
|
{
|
||
|
for (int i = 0; i < count(); ++i) {
|
||
15 years ago
|
TQWidget *w = item(i);
|
||
15 years ago
|
w->setBackgroundMode( bmode );
|
||
|
w->update();
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void QDesignerToolBox::itemInserted( int index )
|
||
15 years ago
|
{
|
||
|
if (count() > 1)
|
||
|
item(index)->setBackgroundMode(item(index>0?0:1)->backgroundMode());
|
||
|
}
|