diff options
Diffstat (limited to 'kommander/editor/widgetfactory.cpp')
-rw-r--r-- | kommander/editor/widgetfactory.cpp | 181 |
1 files changed, 89 insertions, 92 deletions
diff --git a/kommander/editor/widgetfactory.cpp b/kommander/editor/widgetfactory.cpp index a59eb191..d22d63f2 100644 --- a/kommander/editor/widgetfactory.cpp +++ b/kommander/editor/widgetfactory.cpp @@ -18,6 +18,10 @@ ** **********************************************************************/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <tdelocale.h> #include <kommanderfactory.h> @@ -184,7 +188,7 @@ int QDesignerTabWidget::count() const bool QDesignerTabWidget::eventFilter( TQObject *o, TQEvent *e ) { - if ( TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(tabBar()) ) return false; + if ( o != tabBar() ) return false; switch ( e->type() ) { case TQEvent::MouseButtonPress: { @@ -413,7 +417,7 @@ void WidgetFactory::saveDefaultProperties( TQWidget *w, int id ) static void saveChangedProperties( TQWidget *w, int id ) { - TQStringList l = MetaDataBase::changedProperties( TQT_TQOBJECT(w) ); + TQStringList l = MetaDataBase::changedProperties( w ); changedProperties->insert( id, l ); } @@ -464,7 +468,7 @@ int EditorTabWidget::count() const bool EditorTabWidget::eventFilter( TQObject *o, TQEvent *e ) { - if ( TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(tabBar()) ) return false; + if ( o != tabBar() ) return false; switch ( e->type() ) { case TQEvent::MouseButtonPress: { @@ -636,7 +640,7 @@ int EditorToolBox::count() const created. */ -TQWidget *WidgetFactory::create( int id, TQWidget *parent, const char *name, bool init, const TQRect *r, Qt::Orientation orient ) +TQWidget *WidgetFactory::create( int id, TQWidget *parent, const char *name, bool init, const TQRect *r, TQt::Orientation orient ) { TQString n = WidgetDatabase::className(id); //tqDebug("Trying to create '%s'", n.latin1()); @@ -658,7 +662,7 @@ TQWidget *WidgetFactory::create( int id, TQWidget *parent, const char *name, boo w = createCustomWidget(parent, name ? name : s, MetaDataBase::customWidget(id)); if (!w) return 0; - MetaDataBase::addEntry(TQT_TQOBJECT(w)); + MetaDataBase::addEntry(w); if (!defaultProperties->contains(id)) saveDefaultProperties(w, id); @@ -678,7 +682,7 @@ TQLayout *WidgetFactory::createLayout( TQWidget *widget, TQLayout *layout, Layou int margin = 0; if ( widget && !widget->inherits( "TQLayoutWidget" ) && - ( WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(widget) ) ) ) || + ( WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( widget ) ) ) || widget && widget->parentWidget() && widget->parentWidget()->inherits( "FormWindow" ) ) ) margin = MainWindow::self->currentLayoutDefaultMargin(); @@ -697,35 +701,35 @@ TQLayout *WidgetFactory::createLayout( TQWidget *widget, TQLayout *layout, Layou if ( !layout && widget && widget->inherits( "TQWidgetStack" ) ) widget = ((TQWidgetStack*)widget)->visibleWidget(); - MetaDataBase::addEntry( TQT_TQOBJECT(widget) ); + MetaDataBase::addEntry( widget ); if ( !layout && widget && widget->inherits( "TQGroupBox" ) ) { TQGroupBox *gb = (TQGroupBox*)widget; - gb->setColumnLayout( 0, Qt::Vertical ); + gb->setColumnLayout( 0, TQt::Vertical ); gb->layout()->setMargin( 0 ); gb->layout()->setSpacing( 0 ); TQLayout *l; switch ( type ) { case HBox: l = new TQHBoxLayout( gb->layout() ); - MetaDataBase::setMargin( TQT_TQOBJECT(gb), margin ); - MetaDataBase::setSpacing( TQT_TQOBJECT(gb), spacing ); + MetaDataBase::setMargin( gb, margin ); + MetaDataBase::setSpacing( gb, spacing ); l->setAlignment( AlignTop ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; case VBox: l = new TQVBoxLayout( gb->layout(), spacing ); - MetaDataBase::setMargin( TQT_TQOBJECT(gb), margin ); - MetaDataBase::setSpacing( TQT_TQOBJECT(gb), spacing ); + MetaDataBase::setMargin( gb, margin ); + MetaDataBase::setSpacing( gb, spacing ); l->setAlignment( AlignTop ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; case Grid: l = new QDesignerGridLayout( gb->layout() ); - MetaDataBase::setMargin( TQT_TQOBJECT(gb), margin ); - MetaDataBase::setSpacing( TQT_TQOBJECT(gb), spacing ); + MetaDataBase::setMargin( gb, margin ); + MetaDataBase::setSpacing( gb, spacing ); l->setAlignment( AlignTop ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; default: return 0; @@ -736,24 +740,24 @@ TQLayout *WidgetFactory::createLayout( TQWidget *widget, TQLayout *layout, Layou switch ( type ) { case HBox: l = new TQHBoxLayout( layout ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); l->setSpacing( spacing ); l->setMargin( margin ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; case VBox: l = new TQVBoxLayout( layout ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); l->setSpacing( spacing ); l->setMargin( margin ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; case Grid: { l = new QDesignerGridLayout( layout ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); l->setSpacing( spacing ); l->setMargin( margin ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; } default: @@ -764,39 +768,39 @@ TQLayout *WidgetFactory::createLayout( TQWidget *widget, TQLayout *layout, Layou switch ( type ) { case HBox: l = new TQHBoxLayout( widget ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); if ( widget ) { - MetaDataBase::setMargin( TQT_TQOBJECT(widget), margin ); - MetaDataBase::setSpacing( TQT_TQOBJECT(widget), spacing ); + MetaDataBase::setMargin( widget, margin ); + MetaDataBase::setSpacing( widget, spacing ); } else { l->setMargin( margin ); l->setSpacing( margin ); } - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; case VBox: l = new TQVBoxLayout( widget ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); if ( widget ) { - MetaDataBase::setMargin( TQT_TQOBJECT(widget), margin ); - MetaDataBase::setSpacing( TQT_TQOBJECT(widget), spacing ); + MetaDataBase::setMargin( widget, margin ); + MetaDataBase::setSpacing( widget, spacing ); } else { l->setMargin( margin ); l->setSpacing( margin ); } - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; case Grid: { l = new QDesignerGridLayout( widget ); - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); if ( widget ) { - MetaDataBase::setMargin( TQT_TQOBJECT(widget), margin ); - MetaDataBase::setSpacing( TQT_TQOBJECT(widget), spacing ); + MetaDataBase::setMargin( widget, margin ); + MetaDataBase::setSpacing( widget, spacing ); } else { l->setMargin( margin ); l->setSpacing( margin ); } - MetaDataBase::addEntry( TQT_TQOBJECT(l) ); + MetaDataBase::addEntry( l ); return l; } default: @@ -830,7 +834,7 @@ void WidgetFactory::deleteLayout( TQWidget *widget ) */ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *parent, const char *name, bool init, - const TQRect *r, Qt::Orientation orient ) + const TQRect *r, TQt::Orientation orient ) { if (className == "TQPushButton") { @@ -951,8 +955,8 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare if (init) { l->setText(TQString::fromLatin1(name)); - MetaDataBase::addEntry(TQT_TQOBJECT(l)); - MetaDataBase::setPropertyChanged(TQT_TQOBJECT(l), "text", true); + MetaDataBase::addEntry(l); + MetaDataBase::setPropertyChanged(l, "text", true); } return l; } else if (className == "TQLayoutWidget") @@ -965,11 +969,11 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare FormWindow *fw = find_formwindow(parent); TQWidget *w = fw ? new QDesignerWidget(fw, tw, "tab") : new TQWidget(tw, "tab"); tw->addTab(w, i18n("Tab 1")); - MetaDataBase::addEntry(TQT_TQOBJECT(w)); + MetaDataBase::addEntry(w); w = fw ? new QDesignerWidget(fw, tw, "tab") : new TQWidget(tw, "tab"); tw->addTab(w, i18n("Tab 2")); - MetaDataBase::addEntry(TQT_TQOBJECT(tw)); - MetaDataBase::addEntry(TQT_TQOBJECT(w)); + MetaDataBase::addEntry(tw); + MetaDataBase::addEntry(w); } return tw; } else if (className == "TQComboBox") @@ -985,7 +989,7 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare if (fw) { QDesignerWidget *dw = new QDesignerWidget(fw, parent, name); - MetaDataBase::addEntry(TQT_TQOBJECT(dw)); + MetaDataBase::addEntry(dw); return dw; } } @@ -1010,25 +1014,25 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare if (init && parent && parent->inherits("FormWindow")) { QDesignerWidget *dw = new QDesignerWidget((FormWindow *) parent, wiz, "page"); - MetaDataBase::addEntry(TQT_TQOBJECT(dw)); + MetaDataBase::addEntry(dw); wiz->addPage(dw, i18n("Page")); - TQTimer::singleShot(0, wiz, TQT_SLOT(next())); + TQTimer::singleShot(0, wiz, TQ_SLOT(next())); } return wiz; } else if (className == "Spacer") { Spacer *s = new Spacer(parent, name); - MetaDataBase::addEntry(TQT_TQOBJECT(s)); - MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "orientation", true); - MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "sizeType", true); + MetaDataBase::addEntry(s); + MetaDataBase::setPropertyChanged(s, "orientation", true); + MetaDataBase::setPropertyChanged(s, "sizeType", true); 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); + s->setOrientation(TQt::Vertical); else - s->setOrientation(Qt::Horizontal); + s->setOrientation(TQt::Horizontal); return s; } else if (className == "TQLCDNumber") return new TQLCDNumber(parent, name); @@ -1048,9 +1052,9 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare if (!r->isValid() || r->width() < 2 && r->height() < 2) s->setOrientation(orient); else if (r->width() > r->height()) - s->setOrientation(Qt::Horizontal); - MetaDataBase::addEntry(TQT_TQOBJECT(s)); - MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "orientation", true); + s->setOrientation(TQt::Horizontal); + MetaDataBase::addEntry(s); + MetaDataBase::setPropertyChanged(s, "orientation", true); return s; } else if (className == "TQScrollBar") { @@ -1060,9 +1064,9 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare if (!r->isValid() || r->width() < 2 && r->height() < 2) s->setOrientation(orient); else if (r->width() > r->height()) - s->setOrientation(Qt::Horizontal); - MetaDataBase::addEntry(TQT_TQOBJECT(s)); - MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "orientation", true); + s->setOrientation(TQt::Horizontal); + MetaDataBase::addEntry(s); + MetaDataBase::setPropertyChanged(s, "orientation", true); return s; } else if (className == "TQFrame") { @@ -1074,16 +1078,16 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare } else if (className == "Line") { Line *l = new Line(parent, name); - 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); + MetaDataBase::addEntry(l); + MetaDataBase::setPropertyChanged(l, "orientation", true); + MetaDataBase::setPropertyChanged(l, "frameShadow", true); + MetaDataBase::setPropertyChanged(l, "frameShape", true); 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); + l->setOrientation(TQt::Vertical); return l; } else if (className == "TQMainWindow") { @@ -1091,7 +1095,7 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare mw->setDockEnabled(TQt::DockMinimized, false); QDesignerWidget *dw = new QDesignerWidget((FormWindow *) parent, mw, "central widget"); mw->setDockMenuEnabled(false); - MetaDataBase::addEntry(TQT_TQOBJECT(dw)); + MetaDataBase::addEntry(dw); mw->setCentralWidget(dw); (void) mw->statusBar(); dw->show(); @@ -1152,10 +1156,10 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare if (init && parent && parent->inherits("FormWindow")) { QDesignerWidget *dw = new QDesignerWidget((FormWindow *) parent, wiz, "page"); - MetaDataBase::addEntry(TQT_TQOBJECT(dw)); + MetaDataBase::addEntry(dw); wiz->addPage(dw, i18n("Page 1")); wiz->addPage(dw, i18n("Page 2")); - TQTimer::singleShot(0, wiz, TQT_SLOT(next())); + TQTimer::singleShot(0, wiz, TQ_SLOT(next())); } return wiz; } @@ -1167,11 +1171,11 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare FormWindow *fw = find_formwindow(parent); TQWidget *w = fw ? new QDesignerWidget(fw, tw, "tab") : new TQWidget(tw, "tab"); tw->addTab(w, i18n("Tab 1")); - MetaDataBase::addEntry(TQT_TQOBJECT(w)); + MetaDataBase::addEntry(w); w = fw ? new QDesignerWidget(fw, tw, "tab") : new TQWidget(tw, "tab"); tw->addTab(w, i18n("Tab 2")); - MetaDataBase::addEntry(TQT_TQOBJECT(tw)); - MetaDataBase::addEntry(TQT_TQOBJECT(w)); + MetaDataBase::addEntry(tw); + MetaDataBase::addEntry(w); } return tw; } else if (className == "ToolBox") @@ -1182,11 +1186,11 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare FormWindow *fw = find_formwindow(parent); TQWidget *w = fw ? new QDesignerWidget(fw, tw, "toolbox") : new TQWidget(tw, "toolbox"); tw->addItem(w, i18n("Page 1")); - MetaDataBase::addEntry(TQT_TQOBJECT(w)); + MetaDataBase::addEntry(w); w = fw ? new QDesignerWidget(fw, tw, "toolbox") : new TQWidget(tw, "toolbox"); tw->addItem(w, i18n("Page 2")); - MetaDataBase::addEntry(TQT_TQOBJECT(tw)); - MetaDataBase::addEntry(TQT_TQOBJECT(w)); + MetaDataBase::addEntry(tw); + MetaDataBase::addEntry(w); } return tw; } @@ -1244,9 +1248,9 @@ TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *pare if (!r->isValid() || r->width() < 2 && r->height() < 2) s->setOrientation(orient); else if (r->width() > r->height()) - s->setOrientation(Qt::Horizontal); - MetaDataBase::addEntry(TQT_TQOBJECT(s)); - MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "orientation", true); + s->setOrientation(TQt::Horizontal); + MetaDataBase::addEntry(s); + MetaDataBase::setPropertyChanged(s, "orientation", true); return s; } #endif @@ -1278,14 +1282,14 @@ WidgetFactory::LayoutType WidgetFactory::layoutType( TQWidget *w, TQLayout *&lay w = ((TQWidgetStack*)w)->visibleWidget(); if ( w && w->inherits( "TQSplitter" ) ) - return ( (TQSplitter*)w )->orientation() ==Qt::Horizontal ? HBox : VBox; + return ( (TQSplitter*)w )->orientation() ==TQt::Horizontal ? HBox : VBox; if ( !w || !w->layout() ) return NoLayout; TQLayout *lay = w->layout(); if ( w->inherits( "TQGroupBox" ) ) { - TQObjectList *l = TQT_TQOBJECT(lay)->queryList( "TQLayout" ); + TQObjectList *l = lay->queryList( "TQLayout" ); if ( l && l->first() ) lay = (TQLayout*)l->first(); delete l; @@ -1327,7 +1331,7 @@ WidgetFactory::LayoutType WidgetFactory::layoutType( TQWidget *w ) TQWidget *WidgetFactory::layoutParent( TQLayout *layout ) { - TQObject *o = TQT_TQOBJECT(layout); + TQObject *o = layout; while ( o ) { if ( o->isWidgetType() ) return (TQWidget*)o; @@ -1375,7 +1379,7 @@ TQWidget* WidgetFactory::widgetOfContainer( TQWidget *w ) if ( w->parentWidget() && w->parentWidget()->inherits( "TQWidgetStack" ) ) w = w->parentWidget(); while ( w ) { - if ( WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(w) ) ) ) || + if ( WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( w ) ) ) || w && w->parentWidget() && w->parentWidget()->inherits( "FormWindow" ) ) return w; w = w->parentWidget(); @@ -1391,7 +1395,7 @@ bool WidgetFactory::isPassiveInteractor( TQObject* o ) if ( TQApplication::activePopupWidget() ) // if a popup is open, we have to make sure that this one is closed, else X might do funny things return true; - if ( o->inherits( "TQTabBar" ) || ::tqqt_cast<TQToolBox*>(o->parent()) ) + if ( o->inherits( "TQTabBar" ) || ::tqt_cast<TQToolBox*>(o->parent()) ) return true; else if ( o->inherits( "TQSizeGrip" ) ) return true; @@ -1471,11 +1475,11 @@ void WidgetFactory::initChangedProperties( TQObject *o ) if ( o->inherits( "TQPushButton" ) || o->inherits("TQRadioButton") || o->inherits( "TQCheckBox" ) || o->inherits( "TQToolButton" ) ) MetaDataBase::setPropertyChanged( o, "text", true ); - else if (::tqqt_cast<TQToolButton*>(o) && ::tqqt_cast<TQToolBox*>(widgetOfContainer((TQWidget*)o->parent()))) { - MetaDataBase::setPropertyChanged( o, "usesTextLabel", TRUE ); - MetaDataBase::setPropertyChanged( o, "textLabel", TRUE ); - MetaDataBase::setPropertyChanged( o, "autoRaise", TRUE ); - MetaDataBase::setPropertyChanged( o, "textPosition", TRUE ); + else if (::tqt_cast<TQToolButton*>(o) && ::tqt_cast<TQToolBox*>(widgetOfContainer((TQWidget*)o->parent()))) { + MetaDataBase::setPropertyChanged( o, "usesTextLabel", true ); + MetaDataBase::setPropertyChanged( o, "textLabel", true ); + MetaDataBase::setPropertyChanged( o, "autoRaise", true ); + MetaDataBase::setPropertyChanged( o, "textPosition", true ); } else if ( o->inherits( "TQGroupBox" ) ) MetaDataBase::setPropertyChanged( o, "title", true ); else if ( o->isA( "TQFrame" ) ) { @@ -1494,7 +1498,7 @@ void WidgetFactory::initChangedProperties( TQObject *o ) t->verticalHeader()->setLabel( i, TQString::number( i + 1 ) ); } #endif - } else if ( ::tqqt_cast<TQToolBox*>(o) ) { + } else if ( ::tqt_cast<TQToolBox*>(o) ) { MetaDataBase::setPropertyChanged( o, "currentIndex", true ); MetaDataBase::setPropertyChanged( o, "itemName", true ); MetaDataBase::setPropertyChanged( o, "itemLabel", true ); @@ -1669,7 +1673,7 @@ bool WidgetFactory::canResetProperty( TQObject *w, const TQString &propName ) bool WidgetFactory::resetProperty( TQObject *w, const TQString &propName ) { const TQMetaProperty *p = w->metaObject()->property( w->metaObject()-> - findProperty( propName, true ), true ); + findProperty( propName.latin1(), true ), true ); if (!p ) return false; return p->reset( w ); @@ -1702,7 +1706,7 @@ TQVariant WidgetFactory::defaultValue( TQObject *w, const TQString &propName ) TQString WidgetFactory::defaultCurrentItem( TQObject *w, const TQString &propName ) { const TQMetaProperty *p = w->metaObject()-> - property( w->metaObject()->findProperty( propName, true ), true ); + property( w->metaObject()->findProperty( propName.latin1(), true ), true ); if ( !p ) { int v = defaultValue( w, "alignment" ).toInt(); if ( propName == "hAlign" ) { @@ -1900,17 +1904,10 @@ void TQLayoutWidget::updateSizePolicy() vt |= TQSizePolicy::Maximum; } } -#ifdef USE_QT4 - if ( layout()->expanding() & TQSizePolicy::Horizontally ) - ht = TQSizePolicy::Expanding; - if ( layout()->expanding() & TQSizePolicy::Vertically ) - vt = TQSizePolicy::Expanding; -#else // USE_QT4 if ( layout()->expanding() & TQSizePolicy::Horizontally ) ht = TQSizePolicy::Expanding; if ( layout()->expanding() & TQSizePolicy::Vertically ) vt = TQSizePolicy::Expanding; -#endif // USE_QT4 layout()->invalidate(); } |