PageRenderTime 82ms CodeModel.GetById 41ms app.highlight 7ms RepoModel.GetById 33ms app.codeStats 0ms

/src/libtomahawk/context/pages/WikipediaContext.cpp

http://github.com/tomahawk-player/tomahawk
C++ | 91 lines | 52 code | 22 blank | 17 comment | 12 complexity | 5cc4c6679799416a44a2ce2d2e1fdbe7 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *
 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.
 9 *
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.
14 *
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/>.
17 */
18
19#include "WikipediaContext.h"
20#include "Source.h"
21
22using namespace Tomahawk;
23
24
25void
26WikipediaContext::setArtist( const Tomahawk::artist_ptr& artist )
27{
28    if ( artist.isNull() )
29        return;
30    if ( !m_artist.isNull() && m_artist->name() == artist->name() )
31        return;
32
33    m_artist = artist;
34
35    QString lang = QLocale::system().name().split("_").first();
36    webView()->load( QString( "http://%1.wikipedia.org/w/index.php?useformat=mobile&title=%2" ).arg( lang ).arg( m_artist->name() ) );
37}
38
39
40void
41WikipediaContext::setAlbum( const Tomahawk::album_ptr& album )
42{
43    if ( album.isNull() )
44        return;
45
46    setArtist( album->artist() );
47}
48
49
50void
51WikipediaContext::setQuery( const Tomahawk::query_ptr& query )
52{
53    if ( query.isNull() )
54        return;
55
56    setArtist( Artist::get( query->artist(), false ) );
57}
58
59
60void
61LastfmContext::setArtist( const Tomahawk::artist_ptr& artist )
62{
63    if ( artist.isNull() )
64        return;
65    if ( !m_artist.isNull() && m_artist->name() == artist->name() )
66        return;
67
68    m_artist = artist;
69
70    webView()->load( QString( "http://last.fm/music/%1" ).arg( m_artist->name() ) );
71}
72
73
74void
75LastfmContext::setAlbum( const Tomahawk::album_ptr& album )
76{
77    if ( album.isNull() )
78        return;
79
80    setArtist( album->artist() );
81}
82
83
84void
85LastfmContext::setQuery( const Tomahawk::query_ptr& query )
86{
87    if ( query.isNull() )
88        return;
89
90    setArtist( Artist::get( query->artist(), false ) );
91}