diff -r 6df133bd92e1 -r 075425b8d9a4 radioapp/radiowidgets/src/radiostripbase.cpp --- a/radioapp/radiowidgets/src/radiostripbase.cpp Fri Jun 04 10:21:36 2010 +0100 +++ b/radioapp/radiowidgets/src/radiostripbase.cpp Fri Jun 11 13:38:32 2010 +0300 @@ -34,7 +34,7 @@ mModel( 0 ), mIsCyclic( true ), mAutoCenter( false ), - mSpacing( 0 ), + mOverlap( 0 ), mItemPoolParent( new QGraphicsWidget( NULL ) ), mCurrentIndex( 0 ), mPressedIndex( 0 ), @@ -54,7 +54,7 @@ // so the visibility of the items doesn't need to be modified. mItemPoolParent->setVisible( false ); - connectAndTest( this, SIGNAL(scrollPositionChanged(QPointF)), + Radio::connect( this, SIGNAL(scrollPositionChanged(QPointF)), this, SLOT(scrollPositionChanged(QPointF))); } @@ -124,19 +124,9 @@ /*! * */ -void RadioStripBase::setSpacing( qreal spacing ) +void RadioStripBase::setOverlap( qreal overlap ) { - if ( mSpacing != spacing ) - { - mSpacing = spacing; - - prepareGeometryChange(); - - populateAndLayout(); - - update(); - updateGeometry(); - } + mOverlap = overlap; } /*! @@ -266,17 +256,16 @@ mStripLength = boundingRect().width(); qreal itemSize = mItemSize.width(); - mContentsLength = mModel->rowCount() * (itemSize + mSpacing) + mSpacing; + mContentsLength = mModel->rowCount() * (itemSize - mOverlap); if ( mIsCyclic ) { // if treating the items cyclically, double the content area so it can // be shifted back and forth as you scroll - mContentsLength = mModel->rowCount() * (itemSize + mSpacing); - mContentsLength *= 2.0; + mContentsLength *= 2; } - qreal currPos = mSpacing; + qreal currPos = -mOverlap; for ( int i = 0; i < mModel->rowCount(); ++i ) { if ( currPos > mStripLength ) { @@ -286,13 +275,13 @@ QGraphicsItem* item = constructItem( i, true ); if ( item ) { - item->setPos( QPointF( currPos, mSpacing ) ); - currPos += itemSize + mSpacing; + item->setPos( QPointF( currPos, 0 ) ); + currPos += itemSize - mOverlap; } } QRectF contentsRect(0,0,0,0); - contentsRect.setBottom( itemSize + 2 * mSpacing ); + contentsRect.setBottom( mItemSize.height() ); contentsRect.setRight( mContentsLength ); mStripContainer->setGeometry( contentsRect ); @@ -373,7 +362,7 @@ */ qreal RadioStripBase::indexToOffset( int index ) { - return index * ( mItemSize.width() + mSpacing ) + mSpacing; + return index * ( mItemSize.width() - mOverlap ) - mOverlap; } /*! @@ -382,7 +371,7 @@ int RadioStripBase::offsetToIndex( qreal offset ) { const int rows = mModel->rowCount(); - int index = (int)( ( offset - mSpacing) / ( mItemSize.width() + mSpacing ) ); + int index = (int)( offset / ( mItemSize.width() - mOverlap ) ); if ( mIsCyclic ) { @@ -479,7 +468,7 @@ QGraphicsItem* item = constructItem( i, true ); if ( item ) { - item->setPos( QPointF( indexToOffset( i ), mSpacing ) ); + item->setPos( QPointF( indexToOffset( i ), 0 ) ); } } } @@ -492,7 +481,7 @@ QGraphicsItem* item = constructItem( i, false ); if ( item ) { - item->setPos( QPointF( indexToOffset( i ), mSpacing ) ); + item->setPos( QPointF( indexToOffset( i ), 0 ) ); } } @@ -503,7 +492,7 @@ QGraphicsItem* item = constructItem( i, true ); if ( item ) { - item->setPos( QPointF( indexToOffset( i ), mSpacing ) ); + item->setPos( QPointF( indexToOffset( i ), 0 ) ); } } }