From d6f8bbb45b267065a6907e71ff9c98bb6d161241 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:56:07 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1157658 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdevdesigner/designer/layout.cpp | 234 +++++++++++++++++++-------------------- 1 file changed, 117 insertions(+), 117 deletions(-) (limited to 'kdevdesigner/designer/layout.cpp') diff --git a/kdevdesigner/designer/layout.cpp b/kdevdesigner/designer/layout.cpp index 2926b4f6..1f37ea64 100644 --- a/kdevdesigner/designer/layout.cpp +++ b/kdevdesigner/designer/layout.cpp @@ -29,16 +29,16 @@ #include #include "widgetfactory.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -bool operator<( const QGuardedPtr &p1, const QGuardedPtr &p2 ) +bool operator<( const TQGuardedPtr &p1, const TQGuardedPtr &p2 ) { return p1.operator->() < p2.operator->(); } @@ -61,7 +61,7 @@ bool operator<( const QGuardedPtr &p1, const QGuardedPtr &p2 ) widget is found later by Layout.) */ -Layout::Layout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup, bool splitter ) +Layout::Layout( const TQWidgetList &wl, TQWidget *p, FormWindow *fw, TQWidget *lb, bool doSetup, bool splitter ) : widgets( wl ), parent( p ), formWindow( fw ), isBreak( !doSetup ), useSplitter( splitter ) { widgets.setAutoDelete( FALSE ); @@ -78,11 +78,11 @@ Layout::Layout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, void Layout::setup() { - startPoint = QPoint( 32767, 32767 ); - QValueList lists; - QWidget *lastParent = 0; - QWidgetList *lastList = 0; - QWidget *w = 0; + startPoint = TQPoint( 32767, 32767 ); + TQValueList lists; + TQWidget *lastParent = 0; + TQWidgetList *lastList = 0; + TQWidget *w = 0; // Go through all widgets of the list we got. As we can only // layout widgets which have the same parent, we first do some @@ -96,13 +96,13 @@ void Layout::setup() if ( lastParent != w->parentWidget() ) { lastList = 0; lastParent = w->parentWidget(); - QValueList::Iterator it = lists.begin(); + TQValueList::Iterator it = lists.begin(); for ( ; it != lists.end(); ++it ) { if ( ( *it ).first()->parentWidget() == w->parentWidget() ) lastList = &( *it ); } if ( !lastList ) { - QWidgetList l; + TQWidgetList l; l.setAutoDelete( FALSE ); lists.append( l ); lastList = &lists.last(); @@ -113,7 +113,7 @@ void Layout::setup() // So, now find the list with the most entries lastList = 0; - QValueList::Iterator it = lists.begin(); + TQValueList::Iterator it = lists.begin(); for ( ; it != lists.end(); ++it ) { if ( !lastList || ( *it ).count() > lastList->count() ) lastList = &( *it ); @@ -128,7 +128,7 @@ void Layout::setup() layoutBase != formWindow->mainContainer() ) ) ) ) { widgets.clear(); - startPoint = QPoint( 0, 0 ); + startPoint = TQPoint( 0, 0 ); return; } @@ -142,11 +142,11 @@ void Layout::setup() // widgets to get informed if one gets deleted to be able to // handle that and do not crash in this case for ( w = widgets.first(); w; w = widgets.next() ) { - connect( w, SIGNAL( destroyed() ), - this, SLOT( widgetDestroyed() ) ); - startPoint = QPoint( QMIN( startPoint.x(), w->x() ), + connect( w, TQT_SIGNAL( destroyed() ), + this, TQT_SLOT( widgetDestroyed() ) ); + startPoint = TQPoint( QMIN( startPoint.x(), w->x() ), QMIN( startPoint.y(), w->y() ) ); - geometries.insert( w, QRect( w->pos(), w->size() ) ); + geometries.insert( w, TQRect( w->pos(), w->size() ) ); // Change the Z-order, as saving/loading uses the Z-order for // writing/creating widgets and this has to be the same as in // the layout. Else saving + loading will give different results @@ -157,23 +157,23 @@ void Layout::setup() void Layout::widgetDestroyed() { if ( sender() && sender()->isWidgetType() ) - widgets.removeRef( (QWidget*)sender() ); + widgets.removeRef( (TQWidget*)sender() ); } bool Layout::prepareLayout( bool &needMove, bool &needReparent ) { if ( !widgets.count() ) return FALSE; - for ( QWidget *w = widgets.first(); w; w = widgets.next() ) + for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) w->raise(); needMove = !layoutBase; - needReparent = needMove || ::qt_cast(layoutBase) || ::qt_cast(layoutBase); + needReparent = needMove || ::qt_cast(layoutBase) || ::qt_cast(layoutBase); if ( !layoutBase ) { if ( !useSplitter ) layoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( "QLayoutWidget" ), WidgetFactory::containerOfWidget( parent ) ); else - layoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( "QSplitter" ), + layoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( "TQSplitter" ), WidgetFactory::containerOfWidget( parent ) ); } else { WidgetFactory::deleteLayout( layoutBase ); @@ -182,11 +182,11 @@ bool Layout::prepareLayout( bool &needMove, bool &needReparent ) return TRUE; } -void Layout::finishLayout( bool needMove, QLayout *layout ) +void Layout::finishLayout( bool needMove, TQLayout *layout ) { if ( needMove ) layoutBase->move( startPoint ); - QRect g( QRect( layoutBase->pos(), layoutBase->size() ) ); + TQRect g( TQRect( layoutBase->pos(), layoutBase->size() ) ); if ( WidgetFactory::layoutType( layoutBase->parentWidget() ) == WidgetFactory::NoLayout && !isBreak ) layoutBase->adjustSize(); else if ( isBreak ) @@ -196,9 +196,9 @@ void Layout::finishLayout( bool needMove, QLayout *layout ) layout->activate(); formWindow->insertWidget( layoutBase ); formWindow->selectWidget( layoutBase ); - QString n = layoutBase->name(); + TQString n = layoutBase->name(); if ( n.find( "qt_dead_widget_" ) != -1 ) { - n.remove( 0, QString( "qt_dead_widget_" ).length() ); + n.remove( 0, TQString( "qt_dead_widget_" ).length() ); layoutBase->setName( n ); } } @@ -207,7 +207,7 @@ void Layout::undoLayout() { if ( !widgets.count() ) return; - QMap, QRect>::Iterator it = geometries.begin(); + TQMap, TQRect>::Iterator it = geometries.begin(); for ( ; it != geometries.end(); ++it ) { if ( !it.key() ) continue; @@ -216,9 +216,9 @@ void Layout::undoLayout() } formWindow->selectWidget( layoutBase, FALSE ); WidgetFactory::deleteLayout( layoutBase ); - if ( parent != layoutBase && !::qt_cast(layoutBase) ) { + if ( parent != layoutBase && !::qt_cast(layoutBase) ) { layoutBase->hide(); - QString n = layoutBase->name(); + TQString n = layoutBase->name(); n.prepend( "qt_dead_widget_" ); layoutBase->setName( n ); } else { @@ -232,35 +232,35 @@ void Layout::undoLayout() void Layout::breakLayout() { - QMap rects; + TQMap rects; if ( !widgets.isEmpty() ) { - QWidget *w; + TQWidget *w; for ( w = widgets.first(); w; w = widgets.next() ) rects.insert( w, w->geometry() ); } WidgetFactory::deleteLayout( layoutBase ); bool needReparent = qstrcmp( layoutBase->className(), "QLayoutWidget" ) == 0 || - qstrcmp( layoutBase->className(), "QSplitter" ) == 0 || + qstrcmp( layoutBase->className(), "TQSplitter" ) == 0 || ( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( layoutBase ) ) ) && layoutBase != formWindow->mainContainer() ); - bool needResize = qstrcmp( layoutBase->className(), "QSplitter" ) == 0; + bool needResize = qstrcmp( layoutBase->className(), "TQSplitter" ) == 0; bool add = geometries.isEmpty(); - for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { + for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) { if ( needReparent ) w->reparent( layoutBase->parentWidget(), 0, layoutBase->pos() + w->pos(), TRUE ); if ( needResize ) { - QMap::Iterator it = rects.find( w ); + TQMap::Iterator it = rects.find( w ); if ( it != rects.end() ) - w->setGeometry( QRect( layoutBase->pos() + (*it).topLeft(), (*it).size() ) ); + w->setGeometry( TQRect( layoutBase->pos() + (*it).topLeft(), (*it).size() ) ); } if ( add ) - geometries.insert( w, QRect( w->pos(), w->size() ) ); + geometries.insert( w, TQRect( w->pos(), w->size() ) ); } if ( needReparent ) { layoutBase->hide(); parent = layoutBase->parentWidget(); - QString n = layoutBase->name(); + TQString n = layoutBase->name(); n.prepend( "qt_dead_widget_" ); layoutBase->setName( n ); } else { @@ -275,12 +275,12 @@ void Layout::breakLayout() class HorizontalLayoutList : public QWidgetList { public: - HorizontalLayoutList( const QWidgetList &l ) - : QWidgetList( l ) {} + HorizontalLayoutList( const TQWidgetList &l ) + : TQWidgetList( l ) {} - int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ) { - QWidget *w1 = (QWidget*)item1; - QWidget *w2 = (QWidget*)item2; + int compareItems( TQPtrCollection::Item item1, TQPtrCollection::Item item2 ) { + TQWidget *w1 = (TQWidget*)item1; + TQWidget *w2 = (TQWidget*)item2; if ( w1->x() == w2->x() ) return 0; if ( w1->x() > w2->x() ) @@ -290,7 +290,7 @@ public: }; -HorizontalLayout::HorizontalLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup, bool splitter ) +HorizontalLayout::HorizontalLayout( const TQWidgetList &wl, TQWidget *p, FormWindow *fw, TQWidget *lb, bool doSetup, bool splitter ) : Layout( wl, p, fw, lb, doSetup, splitter ) { if ( doSetup ) @@ -311,11 +311,11 @@ void HorizontalLayout::doLayout() if ( !prepareLayout( needMove, needReparent ) ) return; - QHBoxLayout *layout = (QHBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::HBox ); + TQHBoxLayout *layout = (TQHBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::HBox ); - for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { + for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) { if ( needReparent && w->parent() != layoutBase ) - w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE ); + w->reparent( layoutBase, 0, TQPoint( 0, 0 ), FALSE ); if ( !useSplitter ) { if ( qstrcmp( w->className(), "Spacer" ) == 0 ) layout->addWidget( w, 0, ( (Spacer*)w )->alignment() ); @@ -327,8 +327,8 @@ void HorizontalLayout::doLayout() w->show(); } - if ( ::qt_cast(layoutBase) ) - ( (QSplitter*)layoutBase )->setOrientation( Qt::Horizontal ); + if ( ::qt_cast(layoutBase) ) + ( (TQSplitter*)layoutBase )->setOrientation( Qt::Horizontal ); finishLayout( needMove, layout ); } @@ -339,12 +339,12 @@ void HorizontalLayout::doLayout() class VerticalLayoutList : public QWidgetList { public: - VerticalLayoutList( const QWidgetList &l ) - : QWidgetList( l ) {} + VerticalLayoutList( const TQWidgetList &l ) + : TQWidgetList( l ) {} - int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ) { - QWidget *w1 = (QWidget*)item1; - QWidget *w2 = (QWidget*)item2; + int compareItems( TQPtrCollection::Item item1, TQPtrCollection::Item item2 ) { + TQWidget *w1 = (TQWidget*)item1; + TQWidget *w2 = (TQWidget*)item2; if ( w1->y() == w2->y() ) return 0; if ( w1->y() > w2->y() ) @@ -354,7 +354,7 @@ public: }; -VerticalLayout::VerticalLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup, bool splitter ) +VerticalLayout::VerticalLayout( const TQWidgetList &wl, TQWidget *p, FormWindow *fw, TQWidget *lb, bool doSetup, bool splitter ) : Layout( wl, p, fw, lb, doSetup, splitter ) { if ( doSetup ) @@ -375,11 +375,11 @@ void VerticalLayout::doLayout() if ( !prepareLayout( needMove, needReparent ) ) return; - QVBoxLayout *layout = (QVBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::VBox ); + TQVBoxLayout *layout = (TQVBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::VBox ); - for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { + for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) { if ( needReparent && w->parent() != layoutBase ) - w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE ); + w->reparent( layoutBase, 0, TQPoint( 0, 0 ), FALSE ); if ( !useSplitter ) { if ( qstrcmp( w->className(), "Spacer" ) == 0 ) layout->addWidget( w, 0, ( (Spacer*)w )->alignment() ); @@ -391,8 +391,8 @@ void VerticalLayout::doLayout() w->show(); } - if ( ::qt_cast(layoutBase) ) - ( (QSplitter*)layoutBase )->setOrientation( Qt::Vertical ); + if ( ::qt_cast(layoutBase) ) + ( (TQSplitter*)layoutBase )->setOrientation( Qt::Vertical ); finishLayout( needMove, layout ); } @@ -407,9 +407,9 @@ public: Grid( int rows, int cols ); ~Grid(); - QWidget* cell( int row, int col ) const { return cells[ row * ncols + col]; } - void setCell( int row, int col, QWidget* w ) { cells[ row*ncols + col] = w; } - void setCells( QRect c, QWidget* w ) { + TQWidget* cell( int row, int col ) const { return cells[ row * ncols + col]; } + void setCell( int row, int col, TQWidget* w ) { cells[ row*ncols + col] = w; } + void setCells( TQRect c, TQWidget* w ) { for ( int rows = c.bottom()-c.top(); rows >= 0; rows--) for ( int cols = c.right()-c.left(); cols >= 0; cols--) { setCell(c.top()+rows, c.left()+cols, w); @@ -419,14 +419,14 @@ public: int numCols() const { return ncols; } void simplify(); - bool locateWidget( QWidget* w, int& row, int& col, int& rowspan, int& colspan ); + bool locateWidget( TQWidget* w, int& row, int& col, int& rowspan, int& colspan ); private: void merge(); int countRow( int r, int c ) const; int countCol( int r, int c ) const; - void setRow( int r, int c, QWidget* w, int count ); - void setCol( int r, int c, QWidget* w, int count ); + void setRow( int r, int c, TQWidget* w, int count ); + void setCol( int r, int c, TQWidget* w, int count ); bool isWidgetStartCol( int c ) const; bool isWidgetEndCol( int c ) const; bool isWidgetStartRow( int r ) const; @@ -436,7 +436,7 @@ private: void extendRight(); void extendUp(); void extendDown(); - QWidget** cells; + TQWidget** cells; bool* cols; bool* rows; int nrows, ncols; @@ -446,7 +446,7 @@ private: Grid::Grid( int r, int c ) : nrows( r ), ncols( c ) { - cells = new QWidget*[ r * c ]; + cells = new TQWidget*[ r * c ]; memset( cells, 0, sizeof( cells ) * r * c ); rows = new bool[ r ]; cols = new bool[ c ]; @@ -462,7 +462,7 @@ Grid::~Grid() int Grid::countRow( int r, int c ) const { - QWidget* w = cell( r, c ); + TQWidget* w = cell( r, c ); int i = c + 1; while ( i < ncols && cell( r, i ) == w ) i++; @@ -471,20 +471,20 @@ int Grid::countRow( int r, int c ) const int Grid::countCol( int r, int c ) const { - QWidget* w = cell( r, c ); + TQWidget* w = cell( r, c ); int i = r + 1; while ( i < nrows && cell( i, c ) == w ) i++; return i - r; } -void Grid::setCol( int r, int c, QWidget* w, int count ) +void Grid::setCol( int r, int c, TQWidget* w, int count ) { for (int i = 0; i < count; i++ ) setCell( r + i, c, w ); } -void Grid::setRow( int r, int c, QWidget* w, int count ) +void Grid::setRow( int r, int c, TQWidget* w, int count ) { for (int i = 0; i < count; i++ ) setCell( r, c + i, w ); @@ -534,7 +534,7 @@ bool Grid::isWidgetEndRow( int r ) const bool Grid::isWidgetTopLeft( int r, int c ) const { - QWidget* w = cell( r, c ); + TQWidget* w = cell( r, c ); if ( !w ) return FALSE; return ( !r || cell( r-1, c) != w ) && (!c || cell( r, c-1) != w); @@ -545,7 +545,7 @@ void Grid::extendLeft() int r,c,i; for ( c = 1; c < ncols; c++ ) { for ( r = 0; r < nrows; r++ ) { - QWidget* w = cell( r, c ); + TQWidget* w = cell( r, c ); if ( !w ) continue; int cc = countCol( r, c); @@ -576,7 +576,7 @@ void Grid::extendRight() int r,c,i; for ( c = ncols - 2; c >= 0; c-- ) { for ( r = 0; r < nrows; r++ ) { - QWidget* w = cell( r, c ); + TQWidget* w = cell( r, c ); if ( !w ) continue; int cc = countCol( r, c); @@ -607,7 +607,7 @@ void Grid::extendUp() int r,c,i; for ( r = 1; r < nrows; r++ ) { for ( c = 0; c < ncols; c++ ) { - QWidget* w = cell( r, c ); + TQWidget* w = cell( r, c ); if ( !w ) continue; int cr = countRow( r, c); @@ -637,7 +637,7 @@ void Grid::extendDown() int r,c,i; for ( r = nrows - 2; r >= 0; r-- ) { for ( c = 0; c < ncols; c++ ) { - QWidget* w = cell( r, c ); + TQWidget* w = cell( r, c ); if ( !w ) continue; int cr = countRow( r, c); @@ -692,7 +692,7 @@ void Grid::merge() } } -bool Grid::locateWidget( QWidget* w, int& row, int& col, int& rowspan, int & colspan ) +bool Grid::locateWidget( TQWidget* w, int& row, int& col, int& rowspan, int & colspan ) { int r,c, r2, c2; for ( c = 0; c < ncols; c++ ) { @@ -728,7 +728,7 @@ bool Grid::locateWidget( QWidget* w, int& row, int& col, int& rowspan, int & col -GridLayout::GridLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, const QSize &res, bool doSetup ) +GridLayout::GridLayout( const TQWidgetList &wl, TQWidget *p, FormWindow *fw, TQWidget *lb, const TQSize &res, bool doSetup ) : Layout( wl, p, fw, lb, doSetup ), resolution( res ) { grid = 0; @@ -752,12 +752,12 @@ void GridLayout::doLayout() if ( !grid ) buildGrid(); - QWidget* w; + TQWidget* w; int r, c, rs, cs; for ( w = widgets.first(); w; w = widgets.next() ) { if ( grid->locateWidget( w, r, c, rs, cs) ) { if ( needReparent && w->parent() != layoutBase ) - w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE ); + w->reparent( layoutBase, 0, TQPoint( 0, 0 ), FALSE ); if ( rs * cs == 1 ) { layout->addWidget( w, r, c, ::qt_cast(w) ? ( (Spacer*)w )->alignment() : 0 ); } else { @@ -791,14 +791,14 @@ void GridLayout::buildGrid() // ----------------------------------------------------------------- // We need a list of both start and stop values for x- & y-axis - QValueVector x( widgets.count()*2 ); - QValueVector y( widgets.count()*2 ); + TQValueVector x( widgets.count()*2 ); + TQValueVector y( widgets.count()*2 ); // Using push_back would look nicer, but operator[] is much faster int index = 0; - QWidget* w = 0; + TQWidget* w = 0; for ( w = widgets.first(); w; w = widgets.next() ) { - QRect widgetPos = w->geometry(); + TQRect widgetPos = w->geometry(); x[index] = widgetPos.left(); x[index+1] = widgetPos.right(); y[index] = widgetPos.top(); @@ -811,7 +811,7 @@ void GridLayout::buildGrid() // Remove duplicate x enteries (Remove next, if equal to current) if ( !x.empty() ) { - for (QValueVector::iterator current = x.begin() ; + for (TQValueVector::iterator current = x.begin() ; (current != x.end()) && ((current+1) != x.end()) ; ) if ( (*current == *(current+1)) ) x.erase(current+1); @@ -821,7 +821,7 @@ void GridLayout::buildGrid() // Remove duplicate y enteries (Remove next, if equal to current) if ( !y.empty() ) { - for (QValueVector::iterator current = y.begin() ; + for (TQValueVector::iterator current = y.begin() ; (current != y.end()) && ((current+1) != y.end()) ; ) if ( (*current == *(current+1)) ) y.erase(current+1); @@ -837,7 +837,7 @@ void GridLayout::buildGrid() // Mark the cells in the grid that contains a widget for ( w = widgets.first(); w; w = widgets.next() ) { - QRect c(0,0,0,0), widgetPos = w->geometry(); + TQRect c(0,0,0,0), widgetPos = w->geometry(); // From left til right (not including) for (uint cw=0; cw