~ubuntu-branches/ubuntu/karmic/amarok/karmic

« back to all changes in this revision

Viewing changes to src/context/applets/photos/PhotosScrollWidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2009-09-28 20:43:54 UTC
  • mfrom: (1.77.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090928204354-21nwkd4dqlvz3jk3
Tags: 2:2.2.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
    if ( list == m_currentlist )
113
113
        return;
114
114
 
115
 
    debug() << "adding " << list.count() << "new pics";
 
115
  //  debug() << "adding " << list.count() << "new pics";
116
116
    // If a new one arrived, we change.
117
117
    foreach( PhotosInfo *item, list )
118
118
    {
119
119
        if ( !m_currentlist.contains( item ) )
120
120
        {
121
 
            switch ( m_mode )
 
121
            if ( !item->photo->isNull() )
122
122
            {
123
 
                case PHOTOS_MODE_INTERACTIVE :
 
123
                switch ( m_mode )
124
124
                {
125
 
 
126
 
                    if ( !m_id ) // careful we're animating
 
125
                    case PHOTOS_MODE_INTERACTIVE :
127
126
                    {
128
 
                        Plasma::Animator::self()->stopCustomAnimation( m_id );
129
 
                        m_id = 0;
130
 
                    }
131
 
                    DragPixmapItem *dragpix = new DragPixmapItem( this );
132
 
                    dragpix->setPixmap( The::svgHandler()->addBordersToPixmap(
133
 
                    item->photo->scaledToHeight( (int) size().height() - 4 * m_margin,  Qt::SmoothTransformation ), 5, "", true ) );
134
 
                    dragpix->setPos( m_actualpos, 0 );
135
 
                    dragpix->SetClickableUrl( item->urlpage );
136
 
                    dragpix->show();
137
 
 
138
 
                    m_pixmaplist << dragpix;
139
 
 
140
 
                    int delta = dragpix->boundingRect().width() + m_margin;
141
 
                    m_scrollmax += delta;
142
 
                    m_actualpos += delta;
143
 
 
144
 
                    break;
145
 
                }
146
 
                case PHOTOS_MODE_AUTOMATIC :
147
 
                {
148
 
 
149
 
                    DragPixmapItem *dragpix = new DragPixmapItem( this );
150
 
                    dragpix->setPixmap( The::svgHandler()->addBordersToPixmap(
 
127
 
 
128
                        if ( !m_id ) // careful we're animating
 
129
                        {
 
130
                            Plasma::Animator::self()->stopCustomAnimation( m_id );
 
131
                            m_id = 0;
 
132
                        }
 
133
 
 
134
                        DragPixmapItem *dragpix = new DragPixmapItem( this );
 
135
                        dragpix->setPixmap( The::svgHandler()->addBordersToPixmap(
151
136
                        item->photo->scaledToHeight( (int) size().height() - 4 * m_margin,  Qt::SmoothTransformation ), 5, "", true ) );
152
 
                    dragpix->SetClickableUrl( item->urlpage );
153
 
 
154
 
                    if ( m_id == 0 ) // only pos and show if no animation, otherwise it will be set at the end automatically
155
 
                    {
156
 
                        if ( ! m_pixmaplist.empty() )
157
 
                        {
158
 
                            dragpix->setPos( m_pixmaplist.last()->boundingRect().width() + m_pixmaplist.last()->pos().x() + m_margin , 0 ) ;
159
 
                            dragpix->show();
160
 
                        }
161
 
                        else
162
 
                        {
163
 
                            m_actualpos = 0;
164
 
                            dragpix->setPos( m_actualpos, 0 ) ;
165
 
                            dragpix->show();
166
 
                        }
167
 
                    }
168
 
 
169
 
                    m_pixmaplist << dragpix;
170
 
 
171
 
                    // set a timer after and launch
172
 
                    QTimer::singleShot( m_interval, this, SLOT( automaticAnimBegin() ) );
173
 
 
174
 
                    break;
175
 
                }
176
 
                case PHOTOS_MODE_FADING :
177
 
                {
178
 
 
179
 
                    DragPixmapItem *dragpix = new DragPixmapItem( this );
180
 
                    dragpix->setPixmap( The::svgHandler()->addBordersToPixmap(
181
 
                    item->photo->scaledToHeight( (int) size().height() - 4 * m_margin,  Qt::SmoothTransformation ), 5, "", true ) );
182
 
                    dragpix->setPos( ( size().width() - dragpix->boundingRect().width() ) / 2, 0 );
183
 
                    dragpix->SetClickableUrl( item->urlpage );
184
 
                    dragpix->hide();
185
 
                    m_pixmaplist << dragpix;
186
 
                    if ( m_pixmaplist.size() == 1 )
187
 
                    {
 
137
                        dragpix->setPos( m_actualpos, 0 );
 
138
                        dragpix->SetClickableUrl( item->urlpage );
188
139
                        dragpix->show();
189
 
                        m_timer->start( m_interval );
190
 
                    }
191
 
 
192
 
                    break;
 
140
 
 
141
                        m_pixmaplist << dragpix;
 
142
 
 
143
                        int delta = dragpix->boundingRect().width() + m_margin;
 
144
                        m_scrollmax += delta;
 
145
                        m_actualpos += delta;
 
146
 
 
147
                        break;
 
148
                    }
 
149
                    case PHOTOS_MODE_AUTOMATIC :
 
150
                    {
 
151
 
 
152
                        DragPixmapItem *dragpix = new DragPixmapItem( this );
 
153
                        dragpix->setPixmap( The::svgHandler()->addBordersToPixmap(
 
154
                            item->photo->scaledToHeight( (int) size().height() - 4 * m_margin,  Qt::SmoothTransformation ), 5, "", true ) );
 
155
                        dragpix->SetClickableUrl( item->urlpage );
 
156
 
 
157
                        if ( m_id == 0 ) // only pos and show if no animation, otherwise it will be set at the end automatically
 
158
                        {
 
159
                            if ( ! m_pixmaplist.empty() )
 
160
                            {
 
161
                                dragpix->setPos( m_pixmaplist.last()->boundingRect().width() + m_pixmaplist.last()->pos().x() + m_margin , 0 ) ;
 
162
                                dragpix->show();
 
163
                            }
 
164
                            else
 
165
                            {
 
166
                                m_actualpos = 0;
 
167
                                dragpix->setPos( m_actualpos, 0 ) ;
 
168
                                dragpix->show();
 
169
                            }
 
170
                        }
 
171
 
 
172
                        m_pixmaplist << dragpix;
 
173
 
 
174
                        // set a timer after and launch
 
175
                        QTimer::singleShot( m_interval, this, SLOT( automaticAnimBegin() ) );
 
176
 
 
177
                        break;
 
178
                    }
 
179
                    case PHOTOS_MODE_FADING :
 
180
                    {
 
181
 
 
182
                        DragPixmapItem *dragpix = new DragPixmapItem( this );
 
183
                        dragpix->setPixmap( The::svgHandler()->addBordersToPixmap(
 
184
                        item->photo->scaledToHeight( (int) size().height() - 4 * m_margin,  Qt::SmoothTransformation ), 5, "", true ) );
 
185
                        dragpix->setPos( ( size().width() - dragpix->boundingRect().width() ) / 2, 0 );
 
186
                        dragpix->SetClickableUrl( item->urlpage );
 
187
                        dragpix->hide();
 
188
                        m_pixmaplist << dragpix;
 
189
                        if ( m_pixmaplist.size() == 1 )
 
190
                        {
 
191
                            dragpix->show();
 
192
                            m_timer->start( m_interval );
 
193
                        }
 
194
 
 
195
                        break;
 
196
                    }
193
197
                }
194
198
            }
195
199
        }
196
200
    }
197
201
    m_currentlist = list;
198
 
    debug() << "total count: " << m_pixmaplist.count();
 
202
  //  debug() << "total count: " << m_pixmaplist.count();
199
203
}
200
204
 
201
205
void PhotosScrollWidget::hoverEnterEvent(QGraphicsSceneHoverEvent*)
266
270
        {
267
271
            foreach (DragPixmapItem *item, m_pixmaplist)
268
272
            {
269
 
                if ( size().height() != hei )
270
 
                    item->setPixmap( item->pixmap().scaledToHeight( (int) hei - 4 * m_margin,  Qt::SmoothTransformation ) );
271
 
                if ( size().width() != wid )
272
 
                    item->setPos( ( wid - item->boundingRect().width() ) / 2, 0 );
 
273
                if ( !item->pixmap().isNull() )
 
274
                {
 
275
                    if ( size().height() != hei )
 
276
                        item->setPixmap( item->pixmap().scaledToHeight( (int) hei - 4 * m_margin,  Qt::SmoothTransformation ) );
 
277
                    if ( size().width() != wid )
 
278
                        item->setPos( ( wid - item->boundingRect().width() ) / 2, 0 );
 
279
                }
273
280
            }
274
281
            break;
275
282
        }