1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
4
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
6
* Tomahawk is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Tomahawk is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
20
#include "PlaylistView.h"
24
#include "ViewManager.h"
25
#include "PlaylistUpdaterInterface.h"
27
#include "utils/TomahawkUtilsGui.h"
28
#include "utils/Logger.h"
30
using namespace Tomahawk;
33
PlaylistView::PlaylistView( QWidget* parent )
37
connect( contextMenu(), SIGNAL( triggered( int ) ), SLOT( onMenuTriggered( int ) ) );
41
PlaylistView::~PlaylistView()
43
qDebug() << Q_FUNC_INFO;
48
PlaylistView::setModel( QAbstractItemModel* model )
51
qDebug() << "Explicitly use setPlaylistModel instead";
57
PlaylistView::setPlaylistModel( PlaylistModel* model )
61
TrackView::setPlayableModel( m_model );
62
setColumnHidden( PlayableModel::Age, true ); // Hide age column per default
63
setColumnHidden( PlayableModel::Filesize, true ); // Hide filesize column per default
64
setColumnHidden( PlayableModel::Composer, true ); // Hide composer column per default
66
connect( m_model, SIGNAL( playlistDeleted() ), SLOT( onDeleted() ) );
67
connect( m_model, SIGNAL( playlistChanged() ), SLOT( onChanged() ) );
74
PlaylistView::keyPressEvent( QKeyEvent* event )
76
TrackView::keyPressEvent( event );
81
PlaylistView::eventFilter( QObject* obj, QEvent* event )
83
if ( event->type() == QEvent::DragEnter )
85
QDragEnterEvent* e = static_cast<QDragEnterEvent*>(event);
89
if ( event->type() == QEvent::DragMove )
91
QDragMoveEvent* e = static_cast<QDragMoveEvent*>(event);
95
if ( event->type() == QEvent::DragLeave )
97
QDragLeaveEvent* e = static_cast<QDragLeaveEvent*>(event);
101
if ( event->type() == QEvent::Drop )
103
QDropEvent* e = static_cast<QDropEvent*>(event);
108
return QObject::eventFilter( obj, event );
112
QList<PlaylistUpdaterInterface*>
113
PlaylistView::updaters() const
115
if ( !m_model->playlist().isNull() )
116
return m_model->playlist()->updaters();
118
return QList<PlaylistUpdaterInterface*>();
123
PlaylistView::onDeleted()
125
emit destroyed( widget() );
130
PlaylistView::onChanged()
134
if ( m_model->isReadOnly() )
135
setEmptyTip( tr( "This playlist is currently empty." ) );
137
setEmptyTip( tr( "This playlist is currently empty. Add some tracks to it and enjoy the music!" ) );
138
m_model->finishLoading();
140
setGuid( proxyModel()->guid() );
142
if ( !m_model->playlist().isNull() && ViewManager::instance()->currentPage() == this )
143
emit nameChanged( m_model->playlist()->title() );
149
PlaylistView::isTemporaryPage() const
151
return ( m_model && m_model->isTemporary() );
156
PlaylistView::onMenuTriggered( int action )
167
PlaylistView::pixmap() const
169
return TomahawkUtils::defaultPixmap( TomahawkUtils::Playlist );