00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "gamesview.h"
00021 #include "gamesviewitem.h"
00022
00023 #include <QModelIndex>
00024 #include <QGraphicsLinearLayout>
00025
00026 #include <Plasma/ItemBackground>
00027
00028 GamesView::GamesView( QGraphicsItem* parent, Qt::WindowFlags wFlags )
00029 : AbstractItemView( parent, wFlags )
00030 , m_itemBackground(new Plasma::ItemBackground( this ))
00031 {
00032 }
00033
00034 void GamesView::setModel( QAbstractItemModel* model )
00035 {
00036 AbstractItemView::setModel( model );
00037
00038 for( int i = 0; i < m_model->rowCount(); ++i )
00039 {
00040 GamesViewItem* item = new GamesViewItem( this );
00041 item->setModelIndex( m_model->index( i, 0 ) );
00042 item->setAcceptHoverEvents( true );
00043 item->installEventFilter( this );
00044 connect( item, SIGNAL( gameToPlaySelected( QModelIndex ) ), SIGNAL( gameToPlaySelected( QModelIndex ) ) );
00045 connect( item, SIGNAL( gameSelected( QModelIndex ) ), SIGNAL( gameSelected( QModelIndex ) ) );
00046 m_contentLayout->addItem( item );
00047 }
00048 }
00049
00050 bool GamesView::eventFilter( QObject* obj, QEvent* event )
00051 {
00052 if( event->type() == QEvent::GraphicsSceneHoverEnter )
00053 {
00054 QGraphicsItem* item = qobject_cast<QGraphicsItem*> ( obj );
00055 m_itemBackground->setTargetItem( item );
00056 }
00057
00058 return QObject::eventFilter( obj, event );
00059 }
00060
00061 #include "gamesview.moc"