1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
5
* Tomahawk is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* Tomahawk is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
19
#include "SourceInfoWidget.h"
20
#include "ui_SourceInfoWidget.h"
23
#include "ViewManager.h"
25
#include "playlist/AlbumModel.h"
26
#include "playlist/RecentlyAddedModel.h"
27
#include "playlist/RecentlyPlayedModel.h"
29
#include "database/Database.h"
30
#include "database/DatabaseCommand_AllAlbums.h"
32
#include "utils/TomahawkUtilsGui.h"
33
#include "utils/Logger.h"
36
SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget* parent )
38
, ui( new Ui::SourceInfoWidget )
43
TomahawkUtils::unmarginLayout( layout() );
44
TomahawkUtils::unmarginLayout( ui->horizontalLayout );
45
TomahawkUtils::unmarginLayout( ui->verticalLayout );
46
TomahawkUtils::unmarginLayout( ui->verticalLayout_2 );
47
TomahawkUtils::unmarginLayout( ui->verticalLayout_3 );
49
ui->splitter->setStretchFactor( 0, 0 );
50
ui->splitter->setStretchFactor( 1, 1 );
52
m_recentTracksModel = new RecentlyAddedModel( ui->recentCollectionView );
53
ui->recentCollectionView->proxyModel()->setStyle( PlayableProxyModel::Short );
54
ui->recentCollectionView->setPlayableModel( m_recentTracksModel );
55
ui->recentCollectionView->sortByColumn( PlayableModel::Age, Qt::DescendingOrder );
56
m_recentTracksModel->setSource( source );
58
m_historyModel = new RecentlyPlayedModel( ui->historyView );
59
ui->historyView->proxyModel()->setStyle( PlayableProxyModel::Short );
60
ui->historyView->setPlaylistModel( m_historyModel );
61
m_historyModel->setSource( source );
63
m_recentAlbumModel = new AlbumModel( ui->recentAlbumView );
64
ui->recentAlbumView->setPlayableModel( m_recentAlbumModel );
65
ui->recentAlbumView->proxyModel()->sort( -1 );
67
onCollectionChanged();
68
connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ) );
70
m_title = tr( "New Additions" );
71
if ( source->isLocal() )
73
m_description = tr( "My recent activity" );
77
m_description = tr( "Recent activity from %1" ).arg( source->friendlyName() );
82
SourceInfoWidget::~SourceInfoWidget()
89
SourceInfoWidget::onCollectionChanged()
91
loadRecentAdditions();
96
SourceInfoWidget::loadRecentAdditions()
98
m_recentAlbumModel->addFilteredCollection( m_source->collection(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
103
SourceInfoWidget::changeEvent( QEvent* e )
105
QWidget::changeEvent( e );
108
case QEvent::LanguageChange:
109
ui->retranslateUi( this );
119
SourceInfoWidget::pixmap() const
121
return TomahawkUtils::defaultPixmap( TomahawkUtils::NewAdditions, TomahawkUtils::Original );