defuze.me  Client
playqueuewidget.cpp
00001 /**************************************************************************
00002 ** defuze.me Epitech Innovative Project
00003 **
00004 ** Copyright 2010-2011
00005 **   Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard
00006 **   Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier
00007 **
00008 ** All rights reserved.
00009 **************************************************************************/
00010 
00011 #include "playqueuewidget.hpp"
00012 #include "ui_playqueuewidget.h"
00013 #include "playqueue.hpp"
00014 #include "playqueuedelegate.hpp"
00015 #include <QKeyEvent>
00016 #include <QDebug>
00017 
00018 using namespace Queue;
00019 
00020 PlayQueueWidget::PlayQueueWidget(QAbstractItemModel *model) : Gui::ModuleWidget()
00021 {
00022     setupUi(this);
00023     list->setModel(model);
00024     list->setItemDelegate(new PlayQueueDelegate(static_cast<PlayQueue*>(model)));
00025     connect(list, SIGNAL(focusOut()), SIGNAL(clearListFocus()));
00026 }
00027 
00028 PlayQueueWidget::~PlayQueueWidget()
00029 {
00030 }
00031 
00032 void    PlayQueueWidget::setItemWidget(const QModelIndex &index, QWidget *widget)
00033 {
00034     if (!list->indexWidget(index))
00035         list->setIndexWidget(index, widget);
00036 }
00037 
00038 QItemSelectionModel*    PlayQueueWidget::selectionModel() const
00039 {
00040     return list->selectionModel();
00041 }
00042 
00043 void    PlayQueueWidget::keyReleaseEvent(QKeyEvent *event)
00044 {
00045     if (event->matches(QKeySequence::Delete) || (event->key() == Qt::Key_Backspace))
00046     {
00047         emit deleteElements();
00048     }
00049     else
00050         QWidget::keyReleaseEvent(event);
00051 }