00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Shantanu Tushar <jhahoneyk@gmail.com> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #include "highscoresviewitem.h" 00021 #include "models/highscoresmodel.h" 00022 00023 #include <Plasma/IconWidget> 00024 #include <Plasma/Label> 00025 00026 HighScoresViewItem::HighScoresViewItem( QGraphicsItem* parent, Qt::WindowFlags wFlags ) 00027 : QGraphicsWidget( parent, wFlags ) 00028 , m_playerName( 0 ) 00029 , m_score( 0 ) 00030 { 00031 } 00032 00033 HighScoresViewItem::~HighScoresViewItem() 00034 { 00035 } 00036 00037 void HighScoresViewItem::setModelIndex( const QModelIndex& index ) 00038 { 00039 m_index = index; 00040 layoutWidgets(); 00041 } 00042 00043 QModelIndex HighScoresViewItem::modelIndex() const 00044 { 00045 return m_index; 00046 } 00047 00048 void HighScoresViewItem::layoutWidgets() 00049 { 00050 m_playerName = new Plasma::IconWidget( this ); 00051 m_playerName->setText( m_index.sibling( m_index.row(), GluonPlayer::HighScoresModel::NameColumn ).data().toString() ); 00052 00053 m_score = new Plasma::Label( this ); 00054 m_score->setText( m_index.sibling( m_index.row(), GluonPlayer::HighScoresModel::HighScoreColumn ).data().toString() ); 00055 00056 m_level = new Plasma::Label( this ); 00057 m_level->setText( m_index.sibling( m_index.row(), GluonPlayer::HighScoresModel::LevelColumn ).data().toString() ); 00058 00059 m_layout = new QGraphicsLinearLayout(); 00060 m_layout->addItem( m_playerName ); 00061 m_layout->addItem( m_score ); 00062 m_layout->addItem( m_level ); 00063 setLayout( m_layout ); 00064 }